Simple :id
A single path parameter replaced from the variables object.
// 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// run the request to see the responseRequests
as the browser recorded them and the site's server told of them
Nested :id/posts/:postId
Multiple path params in a single URL — all replaced from variables.
// 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// run the request to see the responseRequests
as the browser recorded them and the site's server told of them
Query Params
Variables that don't match a :placeholder become query parameters.
// 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// run the request to see the responseRequests
as the browser recorded them and the site's server told of them
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.
// 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// run the request to see the responseRequests
as the browser recorded them and the site's server told of them