Your first request
This program lists the projects in an organization. SetPHOTON_API_KEY to an
account service key or a service identity credential, and
PHOTON_ORGANIZATION_ID to the ID of an organization it can access.
"serviceIdentityBearer" instead. See Credentials.
How calls are shaped
- TypeScript
- Python
- Rust
Methods are grouped into namespaces that follow the API paths, such as
photon.organizations.projects.list. Each method takes one object with the
members the endpoint declares:path: path parameters, such as{ organizationId }.query: query parameters, such as{ pageSize: 10 }.headers: header parameters, under the contract’s names. Where the contract spells the headerIdempotency-Key, write itidempotencyKey; other header names are written as the contract spells them, such as"idempotency-key","content-type", and"content-length"foruploadAttachment.body: the request body.
{ signal, headers } for one call: an AbortSignal to cancel it, and extra
headers to send.
Request values are typed by the contract and sent as given. Rules such as
patterns, lengths, and ranges are checked by the API, which answers with an
error such as
VALIDATION_FAILED when a value breaks one. See
Errors.
Send a body and headers
Creating a project takes a path parameter, anIdempotency-Key header, and a
JSON body. Retries and timeouts
explains the idempotency key. The Rust example generates the key with the
rand crate; add it with cargo add rand.
Change the base URL
The clients callhttps://api.photon.codes. To call another address, such as a
local mock server in tests, set the base URL when you create the client.
fetch option in TypeScript,
client= (an httpx.Client for Photon, an httpx.AsyncClient for
AsyncPhoton) in Python, and reqwest_client on the Rust builder. The base URL,
timeout, and retry settings still apply, except that in Rust the builder’s
timeout is no longer also the connect timeout: configure that on your
reqwest::Client. In Python, a client you pass in is not closed for you.