How to make a REST API request
You need Landscape 24.04 LTS to use the REST API. This API is only available for self-hosted accounts at this time.
This guide demonstrates how to make a request using the Landscape REST API from a self-hosted Landscape account. The general steps and an example using curl
are provided.
Make a REST API request with your preferred API tool
The general steps to make a REST API request are:
- Provide your login credentials with
POST
- Copy your token from the output
- Assign your token to a new variable, such as
JWT
- Make your API request, using your token for authorisation
Make a REST API request with curl
To make a REST API request with curl
:
-
Provide your login credentials with
POST
. Your request will be similar to the followingcurl -X POST "https://your-landscape.domain.com/api/v2/login" -d '{"email": "jane@example.com", "password": "jane-pwd", "account": "standalone"}'
And you’ll receive output similar to:
{ "accounts": [ { "default": true, "name": "standalone", "title": "Jane-Organisation" } ], "current_account": "standalone", "email": "jane@example.com", "name": "Jane Smith", "token": "qkJ0eXAiOiJKV1QiLCJhbGciOiJskdi296MTcxMDM2MTQxNiwic3ViIjoieWFuaXNhLnNjaGVyYmVyQGNhbm9uaWNhbC5jb20iLCJhY2MiOiJzdGFuZGFsb2i93nboPRfXp50" }
-
Copy your token from the output and assign it to a new variable, such as
JWT
:JWT="qkJ0eXAiOiJKV1QiLCJhbGciOiJskdi296MTcxMDM2MTQxNiwic3ViIjoieWFuaXNhLnNjaGVyYmVyQGNhbm9uaWNhbC5jb20iLCJhY2MiOiJzdGFuZGFsb2i93nboPRfXp50"
-
Make your API request, using your token as authorisation. For example:
curl -X GET https://your-landscape.domain.com/api/v2/activities -H "Authorization: Bearer $JWT"