Skip to content

scaleway/scaleway-sdk-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8c2f4f2 Â· Dec 30, 2024
Nov 14, 2024
Feb 15, 2024
Aug 26, 2024
Dec 30, 2024
Jul 8, 2022
Jul 8, 2022
Jul 8, 2022
Jul 8, 2022
Jul 8, 2022
Feb 21, 2023
Jul 8, 2022
May 16, 2023
Nov 4, 2024
Aug 1, 2023
Nov 14, 2024
Nov 18, 2024
Jul 8, 2022
Nov 4, 2024
Apr 30, 2024
Oct 13, 2023
Nov 4, 2024

Repository files navigation

Scaleway JS SDK

This SDK enables you to interact with Scaleway APIs.

Note The SDK works exclusively within a Node.js environment, as browser requests are limited by CORS restrictions.

🔗  Important links:

Getting Started

You'll need a pair of access and secret keys to connect to Scaleway API. Please check the documentation on how to retrieve them.

A minimal setup would look like this:

import { Registry, createClient } from '@scaleway/sdk'

const client = createClient({
  accessKey: 'SCWXXXXXXXXXXXXXXXXX',
  secretKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  defaultProjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  defaultRegion: 'fr-par',
  defaultZone: 'fr-par-1',
})

const api = new Registry.v1.API(client)

For a simpler setup, you could retrieve the profile from either the configuration file or the environment variables:

import { 
  loadProfileFromConfigurationFile, 
  // loadProfileFromEnvironmentValues,
} from '@scaleway/configuration-loader'

const profile = loadProfileFromConfigurationFile() // loadProfileFromEnvironmentValues()
const client = createClient(profile)

For more advanced needs, please check the examples.

Pagination

We included some pagination helpers for the methods supporting the feature. Let's take listNamespaces() (Registry product) as an example:

Retrieve the first page:

const namespaces = await api.listNamespaces(/*{ page: 1 }*/)

Retrieve all the pages:

const allNamespaces = await api.listNamespaces().all()

Iterate over the pages:

for await (const page of api.listNamespaces()) {
  // 
}

Types

The project is coded with Typescript, so don't hesitate to take advantage of it.

  1. All types of a product are stored in the Product.version namespace. For instance, the Image interface of Registry v1 can be accessed with Registry.v1.Image.

  2. We export errors in the namespace Errors, allowing you to differentiate the cases (e.g. Errors.PermissionsDeniedError).

Contributing Guidelines

This repository is at its early stage and is still in active development. If you are looking for a way to contribute please read CONTRIBUTING.md.

Reach us

We love feedback. Feel free to reach us on Scaleway Slack community, we are waiting for you on #opensource.