Getting started
Getting started with the Specify SDK.
Prerequisites
NodeJS >= 18.x
[Optional] Typescript >= 4.9
TypeScript vs JavaScript
We recommend using TypeScript for a better developer experience. TypeScript's autocompletion in your editor can save you numerous trips to the documentation by suggesting methods and options from the Specify APIs.
Installation
Let's pretend you have a front-end application structured as follows:
Create a specify directory
You'll start by creating a specify
directory at the application level.
Initialize a JavaScript module
Using your terminal, navigate to the directory.
Within this directory, you initialize a JavaScript module by using the package manager of your choice - preferably the one you use to manage your application.
If you use vanilla JavaScript, you can skip the installation of the typescript
package.
The init command creates a minimal package.json
file where the dev dependencies will be added too. Then, you complete/override the content to match the following:
Note that "type": "module"
is mandatory for the SDK to properly work.
Setup TypeScript
If you use vanilla JavaScript, you can skip this step.
Within the specify
directory, you create a tsconfig.json
file which matches the following configuration:
Prepare the environment secrets
To interact with your Specify repositories you'll need to provide a Personal Access Token that you prefer to keep secret. For that reason, we recommend the use of the dotenv package.
Thus, create a .env
file within the specify
directory:
If you use a version control utility like git, you most likely want to add the specify/.env
file to your ignore configuration.
Get a Personal Access Token from your user settings ↗︎
Create a Specify Client
Within the specify
directory, you create an extract.ts
file. This TypeScript script will handle the extraction process by utilizing the personal access token specified in your .env
file.
If you use vanilla JavaScript, you can name this file extract.js
.
Authenticate
In order to consume the private data from a Specify repository, you must authenticate using your personal access token stored in .env
.
Test your script
From your terminal, launch the script.
You should get a log such as:
Your configuration does not run? Get in touch with us on Discord.
List your organization repositories
Get a list of repositories belonging to your organization.
Last updated