Your first request
From service account to data in a few lines.
This guide takes you from your service account to a first response. You need a service account to follow along.
1. Set your credentials
Keep them out of your code, for example in environment variables:
export ZYMPLER_CLIENT_ID="<your client id>"
export ZYMPLER_CLIENT_SECRET="<your client secret>"2. Get a token and call the API
curl
export ZYMPLER_TOKEN=$(curl -s -X POST "https://api.zympler.com/v1beta/oauth/token" \
-d grant_type=client_credentials \
-d client_id="$ZYMPLER_CLIENT_ID" \
-d client_secret="$ZYMPLER_CLIENT_SECRET" | jq -r .access_token)
curl -X GET "https://api.zympler.com/v1beta/organisations" \
-H "Authorization: Bearer $ZYMPLER_TOKEN"Rust
# Cargo.toml
[dependencies]
reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }#[derive(serde::Deserialize)]
struct TokenResponse {
access_token: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let http = reqwest::Client::new();
let client_id = std::env::var("ZYMPLER_CLIENT_ID")?;
let client_secret = std::env::var("ZYMPLER_CLIENT_SECRET")?;
let token = http
.post("https://api.zympler.com/v1beta/oauth/token")
.form(&[
("grant_type", "client_credentials"),
("client_id", client_id.as_str()),
("client_secret", client_secret.as_str()),
])
.send()
.await?
.error_for_status()?
.json::<TokenResponse>()
.await?
.access_token;
let body: serde_json::Value = http
.get("https://api.zympler.com/v1beta/organisations")
.bearer_auth(&token)
.send()
.await?
.error_for_status()?
.json()
.await?;
println!("{body:#}");
Ok(())
}Python
# pip install requests
import os
import requests
token = requests.post(
"https://api.zympler.com/v1beta/oauth/token",
data={
"grant_type": "client_credentials",
"client_id": os.environ["ZYMPLER_CLIENT_ID"],
"client_secret": os.environ["ZYMPLER_CLIENT_SECRET"],
},
timeout=30,
).json()["access_token"]
response = requests.get(
"https://api.zympler.com/v1beta/organisations",
headers={"Authorization": f"Bearer {token}"},
timeout=30,
)
response.raise_for_status()
print(response.json())3. Next steps
This called GET /organisations. Browse the API reference for everything else: each endpoint has examples in curl, Rust and Python, and the language you pick here sticks.