Client SDKs

Tweek has a REST client for javascript/typescript which is suited for both browser/node payload.

tweek-client.

Additionally, there are rich clients for browser that offer batching and caching of requests and React (or react-native) integration. (via HOC or Hooks)

tweek-local-cache
react-tweek

OpenAPI clients

Tweek has an OpenAPI/Swagger specification and it’s possible to generate client SDKs, there’s a WIP repository with generated clients in c#/python/go/java/swift.

https://github.com/Soluto/tweek-openapi-clients

Basic Query

The main API for query Tweek is the values api, you can query it via curl:

https://tweek/api/v2/values/my_app/sign_button/color?user=lily

or

https://tweek/api/v2/values/my_app/sign_button/color?user.country=Canada

The equivalent JS code will be:

const tweekClient = createTweekClient({
  baseServiceUrl: 'https://tweek',
});

let color = await tweekClient.getValues('my_app/sign_button/color', {context: {user: "lily"}});

// OR
color = await tweekClient.getValues('my_app/sign_button/color', {context: {user: {country:"lily"}});

//It's also possible to set context when initializing the client
const client = createTweekClient({
  context: {user: "lily"},
  baseServiceUrl: 'https://tweek',
});

color = await client.getValues('my_app/sign_button/color');

You can see more examples at tweek-client documentation

API for managing Tweek

Tweek can be managed by its apis, the editor itself is a SPA that use the javascript client. For complete api reference, check the OpenAPI spec