Skip to content
msMarketSDK

// guide

SDKs

Every endpoint, as a typed method in your language. The libraries are generated from the same API description as the reference, so they are never behind it.

Install

The six libraries
languageinstallsource
TypeScript, Node and browsersnpm install @marketsdk/jsgithub.com/focussofthq/marketsdk-typescript
Pythonpip install marketsdkgithub.com/focussofthq/marketsdk-python
Gogo get github.com/focussofthq/marketsdk-gogithub.com/focussofthq/marketsdk-go
Javacom.marketsdk:marketsdk-java on Maven Centralgithub.com/focussofthq/marketsdk-java
C#dotnet add package MarketSDKgithub.com/focussofthq/marketsdk-csharp
PHPcomposer require marketsdk/phpgithub.com/focussofthq/marketsdk-php

All six are MIT licensed. Each repository's README has the full usage guide for its language.

A first call

Pass a test key once. The key decides the marketplace and the mode, so there is nothing else to configure. This creates a seller:

TypeScript
import { MarketSDK } from "@marketsdk/js";

const client = new MarketSDK({ token: process.env.MARKETSDK_KEY });
const seller = await client.sellers.createSeller({ external_id: "user_42" });
Python
from marketsdk import MarketSDK

client = MarketSDK(token=os.environ["MARKETSDK_KEY"])
seller = client.sellers.create_seller(external_id="user_42")
Go
import (
    marketsdk "github.com/focussofthq/marketsdk-go"
    "github.com/focussofthq/marketsdk-go/client"
    "github.com/focussofthq/marketsdk-go/option"
)

c := client.NewClient(option.WithToken(os.Getenv("MARKETSDK_KEY")))
seller, err := c.Sellers.CreateSeller(ctx, &marketsdk.CreatePartyDto{ExternalID: "user_42"})
Java
import com.marketsdk.MarketSDK;
import com.marketsdk.types.CreatePartyDto;

MarketSDK client = MarketSDK.builder().token(System.getenv("MARKETSDK_KEY")).build();
SellerObject seller = client.sellers().createSeller(
    CreatePartyDto.builder().externalId("user_42").build());
C#
using MarketSDK;

var client = new MarketSDKClient(Environment.GetEnvironmentVariable("MARKETSDK_KEY"));
var seller = await client.Sellers.CreateSellerAsync(new CreatePartyDto { ExternalId = "user_42" });
PHP
use MarketSDK\MarketSDKClient;
use MarketSDK\Types\CreatePartyDto;

$client = new MarketSDKClient(getenv('MARKETSDK_KEY'));
$seller = $client->sellers->createSeller(new CreatePartyDto(['externalId' => 'user_42']));

What every library does

  • Sends your key as Authorization: Bearer on every call.
  • Lets you set headers per request, which is how you send an Idempotency-Key on a POST.
  • Ignores response fields it does not know, and passes through values it does not know, so an addition to the API never breaks you.
  • Raises or returns a typed error carrying the envelope's code, message, param, and request_id.
  • Retries only on 408, 429, and 5xx responses, honouring Retry-After.
  • Makes no request to anything but the API, and collects nothing.

In the browser

The TypeScript library runs in a browser as well as in Node. Use a publishable key there, never a secret key: the API refuses a secret key sent from a browser. A publishable key reaches published listings, search, and public seller profiles, and nothing else. See authentication.

Versions

Each library has its own version number, starting at 1.0.0, and every release says which version of the API description it was generated from. What counts as a breaking change in a library is on the versioning page.

Something wrong?

Open an issue on the library's repository. Nothing in a library is written by hand, so the fix goes into the generator and every library is regenerated together.

next: authentication