Skip to main content

Get Context API

Get Context API provides a functionality for retrieving a context object from a backend API endpoint using an HTTP GET request. The response is a JSON object containing multiple namespaces, each with its own set of context keys and values. These keys are stored as Context Keys.

This API could be used to pull location information, specific app parameters (for example determine which environment to use staging or production), etc.

This API will be consumed by the Context Setter Plugin.

Request

The Get Context API accepts an HTTP GET request to the endpoint /get-context (for example).

Example request:

GET /get-context HTTP/1.1
Host: example.com

Response

If the backend API endpoint responds with an HTTP status code of 200, the Get Context API will return an HTTP status code of 200 along with the response body, which will be a JSON object with multiple namespaces and their corresponding context keys and values.

Example response body:

{
"version": 1,
"storage_keys": {
"namespace1": {
"contextKey1": "VALUE",
"contextKey2": "VALUE"
},
"namespace2": {
"contextKey1": "VALUE",
"contextKey2": "VALUE"
}
}
}

These values will be stored as Context Keys.

Errors

In case of an error, the backend should return the following error:

  • status (number): the HTTP status code of the error response.
  • message (string): a human-readable error message.

Example error message:

{
"status": 400,
"message": "Invalid query parameter."
}
info

The provided context keys will override any existing context keys currently stored in the app.