UNPKG

4.54 kBMarkdownView Raw
1[![Build Status](https://dev.azure.com/ms/azure-devops-node-api/_apis/build/status/Microsoft.azure-devops-node-api?branchName=master)](https://dev.azure.com/ms/azure-devops-node-api/_build/latest?definitionId=89&branchName=master)
2
3# Azure DevOps Client for Node.js
4
5Integrate with Azure DevOps from your Node.js apps.
6
7### Install the library
8```
9npm install azure-devops-node-api --save
10```
11
12## News
13
14vso-node-api has been renamed and released as azure-devops-node-api
15
16## Get started
17
18### Samples
19
20See [samples](./samples) for complete coding examples
21
22### Install the library
23```
24npm install azure-devops-node-api --save
25```
26
27![Intellisense](docs/intellisense.png)
28
29### Create a connection
30```javascript
31import * as azdev from "azure-devops-node-api";
32
33// your collection url
34let orgUrl = "https://dev.azure.com/yourorgname";
35
36let token: string = process.env.AZURE_PERSONAL_ACCESS_TOKEN;
37
38let authHandler = azdev.getPersonalAccessTokenHandler(token);
39let connection = new azdev.WebApi(orgUrl, authHandler);
40```
41
42> Please note that some API's (e.g. ProfileApi) can't be hit at the org level, and has to be hit at the deployment level,
43so url should be structured like https://**vssps**.dev.azure.com/{yourorgname}
44
45### Get an instance of a client
46
47```javascript
48import * as ba from "azure-devops-node-api/BuildApi";
49
50let build: ba.IBuildApi = await connection.getBuildApi();
51```
52
53#### Available clients
54
55These clients are available:
56
57* Advanced Security Alert
58* Advanced Security Management
59* Build
60* Core
61* Dashboard
62* ExtensionManagement
63* FeatureManagement
64* FileContainer
65* Git
66* Locations
67* Notification
68* Policy
69* Profile
70* ProjectAnalysis
71* Release
72* SecurityRoles
73* TaskAgent
74* Task
75* Test
76* TestPlan
77* TestResults
78* Tfvc
79* Wiki
80* Work
81* WorkItemTracking
82* WorkItemTrackingProcess
83* WorkItemTrackingProcessDefinitions
84
85### Use the client
86
87Coding is easy using linear coding with async/await in TypeScript
88
89```javascript
90import * as bi from "azure-devops-node-api/interfaces/BuildInterfaces";
91
92async function run() {
93 let project: string = "myProject";
94 let defs: bi.DefinitionReference[] = await build.getDefinitions(project);
95
96 defs.forEach((defRef: bi.DefinitionReference) => {
97 console.log(`${defRef.name} (${defRef.id})`);
98 });
99}
100
101run();
102```
103
104## APIs
105
106To see what APIs are available, see the appropriate client interface. For example, [GitApi.ts](https://github.com/Microsoft/azure-devops-node-api/blob/master/api/GitApi.ts)
107
108More 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
109
110## Running Samples
111
112Pre-reqs: [Node >= 16](https://nodejs.org) and [typescript (tsc) >= 4](https://www.npmjs.com/package/typescript)
113
114Run `npm install` first
115
116Set environment variables using set or export:
117
118```bash
119API_URL=https://dev.azure.com/yourorgname
120
121// use your token
122API_TOKEN=cbdeb34vzyuk5l4gxc4qfczn3lko3avfkfqyb47etahq6axpcqha
123
124API_PROJECT=myProject
125```
126
127Run samples:
128
129```bash
130$ npm run samples
131```
132
133Run a specific sample:
134
135```bash
136$ npm run samples -- projectAnalysis
137```
138
139## Node support
140v14 and above - [current, maintained] - Supports node 16 and above
141
142v13 and below - End Of Life, for Node < 16, contains security vulnerabilities, use at your own risk
143
144## API and TFS Mapping
145
146Below you'll find a quick mapping of azure-devops-node-api versions and their corresponding TFS releases. All API versions will work on the TFS version mentioned as well as later TFS versions.
147
148 |**TFS Version** | **Node API VERSION**|
149 |-------------------|------------------|
150 |Azure DevOps Server vNext | 8.0.0|
151 |Azure DevOps Server 2019 | 7.0.0|
152 |TFS 2018 Update 2 | 6.6.2|
153 |TFS 2017 Update 2 | 6.2.8-preview|
154 |TFS 2017 Update 1 | 5.1.2|
155 |TFS 2017 RTW | 5.0.0|
156 |TFS 2015 Update 2 | 0.7.0|
157
158## Contributing
159
160To contribute to this repository, see the [contribution guide](./CONTRIBUTING.md)
161
162## Issues
163
164Feel free to file an issue in this repo.
165
166Do you think there might be a security issue? Have you been phished or identified a security vulnerability? Please don't report it here - let us know by sending an email to secure@microsoft.com.
167
168## Code of Conduct
169
170This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
171
\No newline at end of file