api
api [GET, POST, PUT, PATCH, DELETE, HEAD] [url]
Constructs and sends an http request.
The HTTP GET method requests a representation of the specified resource. Requests using GET should only be used to request data (they shouldn't include data).
e.g.
api get http://api.crul.com/examples
See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET> for complete reference.
api post [url] --data [json]
The HTTP POST method sends data to the server. The type of the body of the request is
indicated by the Content-Type header.
The difference between PUT and POST is that PUT is idempotent: calling it once or several times successively has the same effect (that is no side effect), where successive identical POST may have additional effects, like passing an order several times.
e.g.
api post http://api.crul.com/examples --data '{"bobby": "billy"}'
See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST> for complete reference.
api put [url] --data [json]
The HTTP PUT request method creates a new resource or replaces a representation of
the target resource with the request payload.
The difference between PUT and POST is that PUT is idempotent: calling it once or several times successively has the same effect (that is no side effect), whereas successive identical POST requests may have additional effects, akin to placing an order several times.
e.g.
api put http://api.crul.com/examples --data '{"bobby": "billy"}'
See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT> for complete reference.
api patch [url] --data [json]
The HTTP PATCH request method applies partial modifications to a resource.
PATCH is somewhat analogous to the "update" concept found in CRUD (in general, HTTP is different than CRUD, and the two should not be confused).
PATCH (like POST) may have side-effects on other resources.
e.g.
api patch http://api.crul.com/examples/1 --data '{"bobby": "billy"}'
See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH> for complete reference.
api delete [url]
The HTTP DELETE request method deletes the specified resource.
e.g.
api delete http://api.crul.com/examples/1
See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE> for complete reference.
arguments:
method
The HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD). (type: string)
url
The url for the request. (type: string)
examples:
Query
api get https://pokeapi.co/api/v2/pokemon
Results after api stage:
| count | next | ... |
|---|---|---|
| 1154 | https://pokeapi.co/api/v2/pokemon?offset=20&limit=20 | ... |
flags:
--appendStage
Used to append the results from a previous stage to the current stage. (provide a label, stage index, or boolean true to append the previous results)
--attributes
A comma separated list of attributes to include in the command results. If not provided, all attributes will be included.
--bearer
bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. The name “Bearer authentication” can be understood as “give access to the bearer of this token.” The bearer token is a cryptic string, usually generated by the server in response to a login request.
--cache
A boolean value of true/false that determines whether or not to use the cache. Generally most commands will default to true.
--credentials.oauth
Provider reference stored in vault. Contains the provider and auth related information.
--data
data to send in the body of the request
--enrich
enrich each previous row with the results. The previous columns will be appended with a previous.
--filter
A filter to run on the command results before completing the command. If not provided, no filter is run on the results.
--fresh
Starts the stage as if it was a fresh query, so will not use any previous result.
--headers
headers to send in the request
--labelStage
Used to label a stage with a user provided label.
--pagination
If enabled, will allow for pagination (one api command will make multiple requests according to the pagination strategy described in pagination flags)
--pagination.max
Maximum number of pages visited
--pagination.next
The location within the results set describin the location of the next set of results. If not a complete URL, use the --pagination.url to construct the url using a token
--pagination.url
The url of the next set of results, which can include a token to substitute in the value selected by --pagination.next. If blank, the url is assumed to be contained in the value described by --pagination.next
--params
params to send in the query string for the request
--request
include request data
--response
include response data
--serializer
The serializer to use on response data. 'auto' (default) - Automatically serialize based on the response content-type.
| serializer | content-type/mappping | description |
|---|---|---|
| json | application/json | JSON parse the response text and serialize the response content as a JSON string. |
| xml | application/xml | XML parse the response text and serialize to JSON format. |
| text | text/plain | Serialize the response content as a utf8 string assigned to a content attribiute (e.g., { content: <String> }). |
--stats
Controls if a stats calculation is run on a stage after it completes.
--token.access_token
sets the bearer authentication header (see --bearer) and propogates the token.access_token value to results
--useragent
The User-Agent request header is a characteristic string that lets servers and network peers identify the application, operating system, vendor, and/or version of the requesting user agent. <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent>