Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developers.vendaze.com/llms.txt

Use this file to discover all available pages before exploring further.

There are no official Vendaze SDKs. The API follows standard REST and HTTP conventions and works with any HTTP client. The snippets below cover the most common operations in three languages. Copy, adapt, and ship.
All examples assume you have already completed the OAuth flow and have a valid access_token and refresh_token. See Authentication if you have not done that yet.

Node.js

Uses the built-in fetch API (Node.js 18+). No dependencies required.
// Exchange an authorization code for tokens
async function exchangeCode({ code, clientId, clientSecret }) {
  const res = await fetch('https://api.vendaze.com/oauth/token', {
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    body: new URLSearchParams({
      grant_type: 'authorization_code',
      code,
      client_id: clientId,
      client_secret: clientSecret,
    }),
  });

  if (!res.ok) {
    const { error } = await res.json();
    throw new Error(`${error.code}: ${error.message}`);
  }

  return res.json();
  // { access_token, refresh_token, token_type, expires_in, workspace_slug }
}

Python

Uses the httpx library (async). Install with pip install httpx.
import httpx

async def exchange_code(code: str, client_id: str, client_secret: str) -> dict:
    async with httpx.AsyncClient() as client:
        res = await client.post(
            "https://api.vendaze.com/oauth/token",
            data={
                "grant_type": "authorization_code",
                "code": code,
                "client_id": client_id,
                "client_secret": client_secret,
            },
        )

    res.raise_for_status()
    return res.json()
    # { "access_token": ..., "refresh_token": ..., "workspace_slug": ... }

Go

Uses the standard library only. No external dependencies.
package vendaze

import (
    "encoding/json"
    "fmt"
    "net/http"
    "net/url"
    "strings"
)

type TokenResponse struct {
    AccessToken   string `json:"access_token"`
    RefreshToken  string `json:"refresh_token"`
    TokenType     string `json:"token_type"`
    ExpiresIn     int    `json:"expires_in"`
    WorkspaceSlug string `json:"workspace_slug"`
}

func ExchangeCode(code, clientID, clientSecret string) (*TokenResponse, error) {
    form := url.Values{
        "grant_type":    {"authorization_code"},
        "code":          {code},
        "client_id":     {clientID},
        "client_secret": {clientSecret},
    }

    res, err := http.Post(
        "https://api.vendaze.com/oauth/token",
        "application/x-www-form-urlencoded",
        strings.NewReader(form.Encode()),
    )
    if err != nil {
        return nil, err
    }
    defer res.Body.Close()

    if res.StatusCode != http.StatusOK {
        var errBody struct {
            Error struct {
                Code    string `json:"code"`
                Message string `json:"message"`
            } `json:"error"`
        }
        json.NewDecoder(res.Body).Decode(&errBody)
        return nil, fmt.Errorf("%s: %s", errBody.Error.Code, errBody.Error.Message)
    }

    var tokens TokenResponse
    if err := json.NewDecoder(res.Body).Decode(&tokens); err != nil {
        return nil, err
    }
    return &tokens, nil
}

Community resources

No official SDKs exist yet. If you build a client library for Vendaze, open a pull request on the vendaze/vendaze-api repository to have it listed here.