Skip to content

Rahuletto/codeboard-api

Repository files navigation

⚡ @codeboard/api

API Wrapper of The future of code sharing platform.

Codeboard is an open source code sharing platform thats better in every way. https://cdeboard.vercel.app/docs

Why @codeboard/api ?

  • First-party API Wrapper (Made by the same dev as CodeBoard)
  • Much Efficient
  • Easier approach
  • Type safe
  • Better Intellisense

Documentation

All Class functions/methods returns a Promise so you should await it and should be located inside an async function. Or your project should be configured to top-level await

Summary


CodeBoard

Access the future of code sharing platform with this first-party wrapper

const { CodeBoard } = require("@codeboard/api");

const board = new CodeBoard("API_KEY");
  • Required: API_KEY

The API Key used to access the privileged endpoints like save and fetch. Get your key here

Types

new CodeBoard(key: string): CodeBoard

CodeBoard.ping()

Get the ping latency of the api.

  • Returns One-way travel latency [API --> Client]
  • Multiply the return value by 2 if you need Two-way travel latency [Client <--> API]
const { CodeBoard } = require("@codeboard/api");

const board = new CodeBoard("API_KEY");

await board.ping();

This returns a Promise so you should await it and should be located inside an async function. Or your project should be configured to top-level await

Types

async ping(): Promise<number>

CodeBoard.teapot()

Im a teapot

A very old developers april joke. We won't let it fade away ;)

const { CodeBoard } = require("@codeboard/api");

const board = new CodeBoard("API_KEY");

await board.teapot();

This returns a Promise so you should await it and should be located inside an async function. Or your project should be configured to top-level await

Types

async teapot(): Promise<"Im a teapot">

CodeBoard.save()

Save a board to the CodeBoard

  • Requires: API Key

  • Ratelimits: 20 per minute

const { CodeBoard } = require("@codeboard/api");

const board = new CodeBoard("API_KEY");

await board.save({
  name: "BOARD_NAME",
  description: "BOARD_DESC",
  files: [
    {
      name: "FILE_NAME",
      language: "FILE_LANGUAGE_IN_FULLNAME",
      value: "CODE_SNIPPET",
    },
  ],
});

This returns a Promise so you should await it and should be located inside an async function. Or your project should be configured to top-level await

Types

async save(body: SaveBody): Promise<SaveResponse>
  • SaveBody

{
  name: string;
  description?: string;
  files: BoardFile[];
}
  • SaveResponse

{
  message: string;
  board: string;
  status: number;
  created: boolean;
  url: string;
}

CodeBoard.fetch()

Fetch a board from the CodeBoard with a board id

  • Optional: API Key - will return a encrypted mess if not provided

  • Ratelimits: 40 per minute

const { CodeBoard } = require("@codeboard/api");

const board = new CodeBoard("API_KEY");

await board.fetch("BOARD_ID");

This returns a Promise so you should await it and should be located inside an async function. Or your project should be configured to top-level await

Types

async fetch(id: string): Promise<FetchBody>
  • FetchBody

{
  name: string;
  description: string;
  files: BoardFile[]; // BoardFile type shown below
  url: string;
  key: string;
  createdAt: number;
  encrypted: boolean;
  autoVanish: boolean;
  fork: {
    status: boolean;
    key: string;
    name: string;
  };
  author?: string | null;
  bot: boolean;
  status: number; // HTTP Status Code
}
  • BoardFile

{
  name: string;
  language: string;
  value: string;
}

Support

https://cdeboard.vercel.app/support Let's build a better community, together.

About

API Wrapper of The future of code sharing platform. Codeboard is an open source code sharing platform thats better in every way.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages