CircleCI API Node SDK
The CircleCI API Node SDK is a NPM library for accessing the resources that make up the CircleCI API V2.
SDK Installation
NPM
npm add circleci-v2-sdk
Yarn
yarn add circleci-v2-sdk
import { SDK, withSecurity} from "circleci-v2-sdk";
import { AddEnvironmentVariableToContextRequest, AddEnvironmentVariableToContextResponse } from "circleci-v2-sdk/src/sdk/models/operations";
import { AxiosError } from "axios";
const sdk = new SDK(withSecurity(
security: {
apiKeyHeader: {
apiKey: "YOUR_API_KEY_HERE",
},
}
));
const req: AddEnvironmentVariableToContextRequest = {
pathParams: {
contextId: "sit",
envVarName: "voluptas",
},
request: {
value: "culpa",
},
};
sdk.context.addEnvironmentVariableToContext(req).then((res: AddEnvironmentVariableToContextResponse | AxiosError) => {
// handle response
});
SDK Available Operations
Context
addEnvironmentVariableToContext
– Add or update an environment variablecreateContext
– Create a new contextdeleteContext
– Delete a contextdeleteEnvironmentVariableFromContext
– Remove an environment variablegetContext
– Get a contextlistContexts
– List contextslistEnvironmentVariablesFromContext
– List environment variables
Insights
getAllInsightsBranches
– Get all branches for a projectgetFlakyTests
– Get flaky tests for a projectgetJobTimeseries
– Job timeseries datagetOrgSummaryData
– Get summary metrics with trends for the entire org, and for each project.getProjectWorkflowJobMetrics
– Get summary metrics for a project workflow’s jobs.getProjectWorkflowMetrics
– Get summary metrics for a project’s workflowsgetProjectWorkflowRuns
– Get recent runs of a workflowgetProjectWorkflowTestMetrics
– Get test metrics for a project’s workflowsgetProjectWorkflowsPageData
– Get summary metrics and trends for a project across it’s workflows and branchesgetWorkflowSummary
– Get metrics and trends for workflows
Job
cancelJob
– Cancel jobgetJobArtifacts
– Get a job’s artifactsgetJobDetails
– Get job detailsgetTests
– Get test metadata
Pipeline
continuePipeline
– Continue a pipelinegetPipelineById
– Get a pipeline by IDgetPipelineByNumber
– Get a pipeline by pipeline numbergetPipelineConfigById
– Get a pipeline’s configurationlistMyPipelines
– Get your pipelineslistPipelines
– Get a list of pipelineslistPipelinesForProject
– Get all pipelineslistWorkflowsByPipelineId
– Get a pipeline’s workflowstriggerPipeline
– Trigger a new pipeline
Project
createCheckoutKey
– Create a new checkout keycreateEnvVar
– Create an environment variabledeleteCheckoutKey
– Delete a checkout keydeleteEnvVar
– Delete an environment variablegetCheckoutKey
– Get a checkout keygetEnvVar
– Get a masked environment variablegetProjectBySlug
– Get a projectlistCheckoutKeys
– Get all checkout keyslistEnvVars
– List all environment variables
Schedule
createSchedule
– Create a scheduledeleteScheduleById
– Delete a schedulegetScheduleById
– Get a schedulelistSchedulesForProject
– Get all schedulesupdateSchedule
– Update a schedule
User
getCollaborations
– CollaborationsgetCurrentUser
– User InformationgetUser
– User Information
Webhook
createWebhook
– Create a webhookdeleteWebhook
– Delete a webhookgetWebhookById
– Get a webhookgetWebhooks
– List webhooksupdateWebhook
– Update a webhook
Workflow
approvePendingApprovalJobById
– Approve a jobcancelWorkflow
– Cancel a workflowgetWorkflowById
– Get a workflowlistWorkflowJobs
– Get a workflow’s jobsrerunWorkflow
– Rerun a workflow