Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

cURL examples

Ready-to-run shell scripts for every endpoint of the Openapi OAuth V2 API. Each script prompts for credentials interactively if the environment variables are not set. All scripts are POSIX-compatible and work with sh, bash, and zsh.

Prerequisites

  • curl
  • jq (optional — output is pretty-printed if available, raw JSON otherwise)

Run an example

git clone https://github.com/openapi/get-started-with-oauth-v2.git
cd get-started-with-oauth-v2/examples/curl
sh 00-tokens-create.sh

You can export your credentials once to skip the prompts across all scripts:

export OPENAPI_EMAIL="your@email.com"
export OPENAPI_KEY="your-api-key"

To target the Sandbox instead of production (free, no charges):

export OPENAPI_BASE_URL="https://test.oauth.openapi.com"

Tokens

00 — Create a token

Use this as the first step of any integration: generate a token scoped to only the APIs your app needs. Useful for CI/CD pipelines, backend services, or handing a limited key to a third party.

sh 00-tokens-create.sh

View source →

01 — Create a token with limits

Create a token that caps total requests, wallet spend, and restricts usage to specific IPs. Ideal for partner integrations, sandboxed environments, or pay-per-use services where you want hard cost controls.

sh 01-tokens-create-limits.sh

View source →

02 — List tokens

Audit all active tokens on your account — useful during security reviews, before revoking stale keys, or to check which services are still active.

sh 02-tokens-list.sh

View source →

03 — Get token by ID

Inspect a specific token's scopes, limits, stats, and expiry. Handy when debugging an integration or verifying that limits were applied correctly after creation.

sh 03-tokens-get.sh

View source →

04 — Update a token

Add or remove scopes, extend the TTL, or tighten limits on an existing token — without deleting and recreating it. Useful when requirements change mid-project or you need to grant access to a new API.

sh 04-tokens-update.sh

View source →

05 — Rotate a token (refresh-token flow)

Exchange the refresh token for a brand-new access token and refresh token pair, while preserving all scopes and accumulated stats. Use this for zero-downtime key rotation in production services.

sh 05-tokens-rotate.sh

View source →

06 — Delete a token

Permanently revoke a token. Use this to clean up unused keys, respond to a potential credential leak, or decommission an integration.

sh 06-tokens-delete.sh

View source →


Scopes

07 — List available scopes

Discover all the API endpoints your account has access to, along with their identifiers. Use this before creating a token to know exactly which scope strings to include.

sh 07-scopes-list.sh

View source →

08 — Get scope by ID

Inspect rate limits, free quotas, pricing, and requirements for a specific scope before enabling it on a token. Useful when estimating costs or checking if a scope needs additional account setup.

sh 08-scopes-get.sh

View source →


Stats

09 — Overall usage stats

Get a snapshot of total requests, paid calls, errors, unique IPs, and wallet spend across all APIs. Useful for monthly reporting, cost forecasting, or spotting unexpected usage spikes.

sh 09-stats-overview.sh

View source →

10 — Unique IP list

Retrieve all IP addresses that made requests under your account in a given period. Useful for detecting unexpected callers, auditing access patterns, or building an IP allowlist.

sh 10-stats-ips.sh

View source →

11 — Stats grouped by API domain

See how usage is distributed across all the API domains you consume — total calls, paid calls, errors, and spend per domain. Useful for understanding which integrations drive the most traffic or cost.

sh 11-stats-apis.sh

View source →

12 — Stats for a specific domain

Drill into a single API domain to get per-scope breakdowns, IP lists, and granular metrics. Useful for debugging a specific integration or preparing a domain-level cost report.

sh 12-stats-domain.sh

View source →


Wallet

13 — Wallet balance

Check the current credit available on your account. Use this before running batch jobs or launching a new integration to make sure you have sufficient funds.

sh 13-wallet-balance.sh

View source →

14 — Wallet transactions

Browse the paginated history of credits and charges on your wallet. Useful for reconciling invoices, tracking spend over time, or identifying unexpected deductions.

sh 14-wallet-transactions.sh

View source →


Monitoring

15 — Error logs

List recent API errors with scope, HTTP status, error code, and the originating IP. Use this to diagnose integration failures, spot misconfigured tokens, or investigate 4xx spikes.

sh 15-errors-list.sh

View source →

16 — List callbacks

View recent callback deliveries for async APIs — including destination URL, HTTP response code, and completion status. Useful for verifying that webhooks are reaching your endpoint.

sh 16-callbacks-list.sh

View source →

17 — Get callback by ID

Inspect a single callback in detail: payload, headers, elapsed time, attempt count, and retry history. Use this to debug a failed or slow callback delivery.

sh 17-callbacks-get.sh

View source →

18 — List subscriptions

View active subscriptions on your account, including available requests, expiry dates, and auto-renew status. Useful for checking quota before a high-volume job or managing renewals.

sh 18-subscriptions-list.sh

View source →

19 — Get subscription by ID

Inspect a specific subscription's full detail: pricing, remaining requests, type, and timeline. Useful when evaluating whether to renew, upgrade, or switch to wallet-based billing.

sh 19-subscriptions-get.sh

View source →