🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

vso-node-api

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vso-node-api

Node client for Visual Studio Online/TFS REST APIs

Source
npmnpm
Version
6.1.2-preview
Version published
Weekly downloads
1.9K
-30.22%
Maintainers
1
Weekly downloads
 
Created
Source

Visual Studio Team Services Client for Node.js

Integrate with Visual Studio Team Services from your Node.js apps.

Get started

Samples

See samples for complete coding examples

Install the library

npm install vso-node-api --save

Typings

Typings (.d.ts) are now distributed with the api, so intellisense and compile support just works from tsc and vscode

Intellisense

Create a connection

let vsts = require('vso-node-api');

// your collection url
let collectionUrl = "https://fabrikam.visualstudio.com/defaultcollection";

// ideally from config
let token: string = "cbdeb34vzyuk5l4gxc4qfczn3lko3avfkfqyb47etahq6axpcqha"; 

let authHandler = vsts.getPersonalAccessTokenHandler(token); 
let connect = new vsts.WebApi(collectionUrl, authHandler);    

Get an instance of a client

import * as ba from 'vso-node-api/BuildApi';

let vstsBuild: ba.IBuildApi = connection.getBuildApi();

Available clients

These clients are available in the new 6.x preview API (npm install vso-node-api@preview)

  • Accounts
  • Build
  • Chat
  • Contributions
  • Core
  • Dashboard
  • DelegatedAuthorization
  • ExtensionManagement
  • FeatureManagement
  • FileContainer
  • Gallery
  • Git
  • Identities
  • Licensing
  • Locations
  • Notification
  • Organization
  • Policy
  • Profile
  • Release
  • SecurityRoles
  • ServiceHooks
  • TaskAgent
  • Task
  • Test
  • Tfvc
  • Token
  • Work
  • WorkItemTracking

Use the client

Coding is easy using linear coding with async/await in typescript

import * as bi from 'vso-node-api/interfaces/BuildInterfaces';

async function run() {
    let project: string = 'myProject';
    let defs: bi.DefinitionReference[] = await vstsBuild.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

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:

API_URL=https://fabrikam.visualstudio.com/defaultcollection  

// use your token
API_TOKEN=cbdeb34vzyuk5l4gxc4qfczn3lko3avfkfqyb47etahq6axpcqha  

API_PROJECT=myProject  

Run samples:

$ npm run samples

Run a specific sample:

$ npm run samples -- http

Contributing

To contribute to this repository, see the contribution guide

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

FAQs

Package last updated on 28 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts