This site counts visits with analytics cookies only if you accept. Read the consent

Skip to content

ExamplesPath Parameters

Path Parameters

Dynamic URL segments with :param placeholders, auto-replaced from variables.

Simple :id

A single path parameter replaced from the variables object.

ts
// Method definition with :id placeholder
getById: endpoint.get(":id").variables<{ id: number }>().response<User>()

// Usage — :id is replaced with the value from variables
await caller.users.getById({ id: 1 })
// → GET /users/1
caller.users.getByIdSANDBOX
idle
// run the request to see the response

Requests

as the browser recorded them and the site's server told of them

// no request yet: run the call

Path params docs

Nested :id/posts/:postId

Multiple path params in a single URL — all replaced from variables.

ts
// Multiple path params in one URL
getUserPost: endpoint.get(":id/posts/:postId").variables<{ id: number; postId: number }>().response<UserPostResponse>()

// Both :id and :postId are replaced
await caller.users.getUserPost({ id: 1, postId: 2 })
// → GET /users/1/posts/2
caller.users.getUserPostSANDBOX
idle
// run the request to see the response

Requests

as the browser recorded them and the site's server told of them

// no request yet: run the call

Query Params

Variables that don't match a :placeholder become query parameters.

ts
// Path params + query params work together
// Variables matching :placeholders go into the URL path
// Remaining variables go as query params

getAll: endpoint.get("").variables<{ page?: number; limit?: number }>().response<UsersListResponse>()

// No path params — all variables become ?query params
await caller.users.getAll({ page: 1, limit: 5 })
// → GET /users?page=1&limit=5
caller.users.getAllSANDBOX
idle
// run the request to see the response

Requests

as the browser recorded them and the site's server told of them

// no request yet: run the call

Encoded in the Address

A value with characters the address uses itself is encoded on its way: type any, and the request below shows the path the site's server asked the API for.

ts
// A value is encoded where it goes in the address: a space, &, / or %
// cannot end the value or start another
await caller.users.getAll({ search: "Ann & co / 50%" })
// → GET /users?search=Ann+%26+co+%2F+50%25
caller.users.getAll({ search })SANDBOX
idle
// run the request to see the response

Requests

as the browser recorded them and the site's server told of them

// no request yet: run the call