Skip to content

GET == Read/View

The HTTP GET method is used to read or view data from the API.

Here we will retrieve a list of locations and then retrieve the details of a specific location with ID 1701.

List vs Detail Views

It's important to note that list views (i.e.: /api/locations/) will often [by default] return different, less detailed, data than detail views (i.e.: /api/locations/1701/).

This can be seen and sampled by looking through the API browser pages.

Retrieve List of Locations
curl -s \
    -H "Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    https://deploy.c1engineering.com/api/projects/locations/ | jq
Retrieve Details of Location with ID 1701
curl -s \
    -H "Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    https://deploy.c1engineering.com/api/projects/locations/1701/ | jq
Retrieve List of Locations
Invoke-RestMethod `
    -Headers @{Authorization="Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} `
    -Uri https://deploy.c1engineering.com/api/projects/locations/ | ConvertTo-Json
Retrieve Details of Location with ID 1701
Invoke-RestMethod `
    -Headers @{Authorization="Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} `
    -Uri https://deploy.c1engineering.com/api/projects/locations/1701/ | ConvertTo-Json
Retrieve List of Locations
import json
import requests

response = requests.get(
    'https://deploy.c1engineering.com/api/projects/locations/',
    headers={
        'Authorization':
        'Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    },
)

locations = response.json()

print(json.dumps(locations, indent=4))
Retrieve Details of Location with ID 1701
import json
import requests

response = requests.get(
    'https://deploy.c1engineering.com/api/projects/locations/1701/',
    headers={
        'Authorization':
        'Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    },
)

location = response.json()

print(json.dumps(location, indent=4))