@northflank/js-client
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.0 • Public • Published

    Northflank api-client package

    Node.js client for the Northflank platform based on the Northflank public api.

    Visit our website www.northflank.com

    Full documentation on https://northflank.com/docs/v1/api/use-the-javascript-client

    Also use the Northflank command line interface (CLI): https://www.npmjs.com/package/@northflank/cli

    Please don’t hesitate to get in touch with us if you have a query or want to give some feedback on https://northflank.com/contact or email us at contact@northflank.com.

    Setup

    Add as a dependency to your project with npm i @northflank/js-client or yarn add @northflank/js-client.

    Using the package

    Example usage:

    import { ApiClient, ApiClientInMemoryContextProvider} from '@northflank/js-client';
    
    (async () => {
      // Create context to store credentials.
      const contextProvider = new ApiClientInMemoryContextProvider();
      await contextProvider.addContext({
        name: 'test-context',
        token: '<api-token>', // Use token retrieved from Northflank web interface: Account Settings > API > Tokens > Create API token.
      });
    
      // Initialize API client.
      const apiClient = new ApiClient(contextProvider);
    
      // Retrieve list of projects and log to console.
      const projects = (await apiClient.list.project({})).data.projects;
      console.log(projects);
    
      // Create a new project.
      const project = await apiClient.create.project({
        data: {
          name: 'test-project',
          region: 'europe-west',
          description: 'test project description',
        },
      });
    
      // List services in newly created project
      const { services } = (await apiClient.list.service({ parameters: { projectId: project.data.id } })).data;
      console.log(services.map((svc) => svc.name).join(', '));
    })();
    

    If used with Typescript, full typing support can be leveraged.

    Install

    npm i @northflank/js-client

    DownloadsWeekly Downloads

    364

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    646 kB

    Total Files

    253

    Last publish

    Collaborators

    • nf_marco
    • deciderwill
    • northflank-fred
    • northflank-lavrenti