Skip to content

Auto generated schema based GET ALL BY STREAM API

Table structure

customer_id first_name last_name last_update pincode isActive
1 Bob lin 2022-11-14 04: 34: 58 382345 1
2 Alice Page 2022-10-15 02: 10: 40 382346 1
3 Mallory Brown 2022-09-13 03: 44: 05 382347 1
4 Eve Mathly 2022-11-12 01: 59: 33 382348 1
5 Eve Page 2022-11-12 01: 59: 33 382349 1

Simple get all by a stream

URL

/api/schema/user-path/instance/database/table/stream 

Get by any field

URL

/api/schema/user-path/instance/database/table/stream?customer_id=1

Get by multiple fields

?first_name=Bob&last_name=lin

Skip data

  • It will skip the first 10 documents/rows.
?skip=10
  • It will skip the first 2 documents/rows having pinCode equals "382345"
?pinCode=382345&skip=2

Limit data

  • It will return only 10 documents/rows having first_name equals "Bob"
?first_name=Bob&limit=10

Sort data

  • It will sort documents/rows in order of ascending or descending

  • ascending

?sort=customer_id
  • descending
?sort=-customer_id

Select data

  • It will return only first_name and last_name in response
?select=first_name,last_name

Deep data

  • It will return documents/rows from multiple table combinations.
?deep=[{s_key:'customer_id,t_col: 'products',t_key:'owner_id'}]

Here,

s_key = Source table field
t_col = Target table collection/table name
t_key = Target table field
  • also use multiple query params [skip, limit, sort, find, etc...] in a single deep query.
?deep=[{s_key:'customer_id',t_col:'products',t_key:'owner_id',skip:1,isMultiple:true,limit:5,sort:'name',find:{category_id:{$in:[56572,89355]}}}]

GetTotalCount data

  • It will return an additional parameter of 'totalCount' which indicate the total number of documents/rows get in to the response.
?getTotalCount=true

Find: valid JSON support for fetching data using find.

JSON 5 support

  • It will return documents/rows as per JSON condition.
?find={first_name:'Bob'}

Find: Complex condition support in find query param

  • It will return documents/rows as per the condition
?find={first_name:{$eq:'Bob'}}
?find={first_name:{$in:['Bob','Alice']}}
?find={customer_id:{$gt:3}}
?find={customer_id:{$gte:3}}
?find={customer_id:{$lt:3}}
?find={customer_id:{$lte:3}}
?find={customer_id:{$ne:3}}
?find={first_name:{$nin:['Bob','Alice']}}

Additional Query Param Support

  • It will return documents/rows as per additional query param.
?customer_id=3
?customer_id>3
?customer_id>=3
?customer_id>3&pincode>=5
?first_name=Bob,Alice
?customer_id>3.1

All Query param support in one API

  • It will return documents/rows, that fulfill all query param.
?find={first_name:'Bob'}&skip=1&limit=4&sort=-1&select=first_name&deep=[{s_key:'customer_id,t_col:'products',t_key:'owner_id'}]&getTotalCount=true    

Pre-/Post hooks

  • 'g.res.output' will only have the last written chunk of data.
  • Post hooks will not be able to return data to the user because the response is already sent to the user.

Summary

Key Value
find ?find={first_name:'Bob'}
skip 2
limit 2
sort customer_id
select ?select=first_name,customer_id
deep ?deep=[{s_key:'customer_id,t_col: 'products',t_key:'owner_id'}]
getTotalCount true
All table fields You can use any column name as query params.

Supported headers

Header Description
x-am-response-case It will change the response keys text as requested case.
"x-am-response-case": "camelCase"
noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase
x-am-response-object-type To get flat response we use this request header.
"x-am-response-object-type": "make_flat"
no_action | make_flat
x-am-meta To get the meta-data of requested API.
"x-am-meta": "true"
false | true
x-am-secret Place secret id from API Maker.
"x-am-secret": "6381b80359bdbd3a87c9abd5"
x-am-internationalization We can get backend error messages in any user language and directly show them to the user in UI, so the user can take appropriate actions.
Provide saved internationalization name in request header.
"x-am-internationalization": "HINDI"
x-am-run-in-sandbox System will try to run requests in maximum provided sandbox, so if 1 provided every request will run in one sandbox, even if we have multiple sandbox with multiple API Maker instances.
"x-am-run-in-sandbox": "0"
x-am-content-type-response We can provide response type in request header. As provided header value we can expect the response type.
"x-am-content-type-response": "application/json"
application/json | text/xml | text/yaml
x-am-cache-control To reset the cache of the requested API manually and get fresh data, we can use 'x-am-cache-control' request header.
"x-am-cache-control": "reset_cache"
no_action | reset_cache
x-am-get-encrypted-data Encrypt response data and get in to the response.
"x-am-get-encrypted-data": "get_data_and_encryption"
no_encryption | get_only_encryption | get_data_and_encryption
x-am-authorization Provide token of API user in "x-am-authorization" header which will be generated from API Users inside API Maker.
"x-am-authorization": "eyJhbGciOiJIUzI1NiIsdlRrblJlcS"
x-am-user-authorization User token should be provided in 'x-am-user-authorization' header which will be generated based on some database user if required.
"x-am-user-authorization": "eyJhbGciOiJIpc1BydlRrblJlcS"
x-aws-authorization Provide AWS Cognito token in request header 'x-aws-authorization', if required.
"x-aws-authorization": "eyJhbGciOiJIUc1BdlRrlJlcS"
x-google-authorization Provide Google user token in request header 'x-google-authorization', if required.
"x-google-authorization": "eyJhbGceyJpc1BdlRrlJlcS"
x-azure-authorization Provide Azure active directory token in request header 'x-azure-authorization', if required.
"x-azure-authorization": "eyJhbGciOiJIUzI1NiIJpc1BdlRrlJlcS"
x-no-compression If user do not send 'x-no-compression' in request header, and response characters are more than value of "maxCharsResToCache" than the response will be compressed.
"x-no-compression": "true"
x-am-sandbox-timeout If any API did not give a response within given time, the sandbox will break and give a proper error message in the response.
"x-am-sandbox-timeout": "13000"  // milliseconds
x-am-encrypted-payload When user sent encrypted payload, user must have to sent "x-am-encrypted-payload:true".
"x-am-encrypted-payload": "true"