Client Libraries

We are working on creating libraries for various languages.

In the meantime you can take a look at a couple of sample snippets that we’ve created for the following languages: Golang, Node.js, and Python.

Golang

Below is a small code sample to authenticate and retrieve data about an application on Wercker in Golang.

package main

import (
    "log"
    "net/http"
)

func main() {
    url := "https://app.wercker.com/api/v3/applications/wercker/docs"
    client := &http.Client{}
    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Add("Authorization", "Bearer <TOKEN>")
    resp, err := client.Do(req)
    if err != nil {
        log.Println(err)
    }
    log.Println(resp)
    defer resp.Body.Close()
}

Node.js

Below is a small code sample to authenticate and retrieve data about an application on wercker in Node.js using the request library.

var request = require('request');

var options = {
  url: 'https://app.wercker.com/api/v3/applications/wercker/docs',
  headers: {
    'Authorization': 'Bearer <TOKEN>'
  }
};

function callback(error, response, body) {
  if (!error && response.statusCode == 200) {
    var result = JSON.parse(body);
    console.log(result)
  }
  else {
    console.log(error)
  }
}

request(options, callback);

Python

Below is a small code sample to authenticate and retrieve data about an application on wercker in Python using the requests library.

import requests
import json

url = 'https://app.wercker.com/api/v3/applications/wercker/docs'
headers = {'Authorization':'Bearer <TOKEN>'}
r = requests.get(url, headers=headers, verify=True)
print r.json()