Node client for Azure DevOps and TFS REST APIs
npm install @xiaoxu_dev/azure-devops-node-api
npm install azure-devops-node-api --save
`
News
vso-node-api has been renamed and released as azure-devops-node-api
Get started
$3
See samples for complete coding examples
$3
`
npm install azure-devops-node-api --save
`
!Intellisense
$3
`javascript
import * as azdev from "azure-devops-node-api";
// your collection url
let orgUrl = "https://dev.azure.com/yourorgname";
let token: string = process.env.AZURE_PERSONAL_ACCESS_TOKEN; // e.g "cbdeb34vzyuk5l4gxc4qfczn3lko3avfkfqyb47etahq6axpcqha";
let authHandler = azdev.getPersonalAccessTokenHandler(token);
let connection = new azdev.WebApi(orgUrl, authHandler);
`
$3
`javascript
import * as ba from "azure-devops-node-api/BuildApi";
let build: ba.IBuildApi = await connection.getBuildApi();
`
#### Available clients
These clients are available:
* Build
* Core
* Dashboard
* ExtensionManagement
* FeatureManagement
* FileContainer
* Git
* Locations
* Notification
* Policy
* Profile
* ProjectAnalysis
* Release
* SecurityRoles
* TaskAgent
* Task
* Test
* Tfvc
* Wiki
* Work
* WorkItemTracking
* WorkItemTrackingProcess
* WorkItemTrackingProcessDefinitions
$3
Coding is easy using linear coding with async/await in TypeScript
`javascript
import * as bi from "azure-devops-node-api/interfaces/BuildInterfaces";
async function run() {
let project: string = "myProject";
let defs: bi.DefinitionReference[] = await build.getDefinitions(project);
defs.forEach((defRef: bi.DefinitionReference) => {
console.log(${defRef.name} (${defRef.id}));
});
}
run();
`
APIs
To see what APIs are available, see the appropriate client interface. For example, GitApi.ts
More detailed information for the endpoints of each API can be found at https://docs.microsoft.com/en-us/rest/api/vsts/?view=vsts-rest-4.1
Running Samples
Pre-reqs: Node >= 4.4.7 LTS and typescript (tsc) >= 1.8
Run npm install first
Set environment variables using set or export:
`bash
API_URL=https://dev.azure.com/yourorgname
// use your token
API_TOKEN=cbdeb34vzyuk5l4gxc4qfczn3lko3avfkfqyb47etahq6axpcqha
API_PROJECT=myProject
`
Run samples:
`bash
$ npm run samples
`
Run a specific sample:
`bash
$ npm run samples -- projectAnalysis
``