All Projects → yanatan16 → golang-soundcloud

yanatan16 / golang-soundcloud

Licence: MIT license
A SoundCloud API implementation in Go

Programming Languages

go
31211 projects - #10 most used programming language

golang-soundcloud

A (incomplete) SoundCloud API wrapper.

Features

Implemented:

  • Most GET requests are implemented
  • Both authenticated and unauthenticated requests can be made
  • Refreshes tokens
  • No interface{} data types!

Todo:

  • The full set of GET requests
  • Full Authentication
  • POST / PUT / DELETE requests

Contributing

This API wrapper is a good start, but is no where near completion. If you're using Go and SoundCloud, please consider contributing by implementing more methods (see Issues) and making a pull request. As for style, just use go fmt before you pull!

Documentation

Documentation on godoc.org

Install

go get github.com/yanatan16/golang-soundcloud/soundcloud

Creation

import (
  "github.com/yanatan16/golang-soundcloud/soundcloud"
)

unauthenticatedApi := &soundcloud.Api{
  ClientId: "my-client-id",
}

authenticatedApi := &soundcloud.Api{
  ClientId: "my-client-id",
  ClientSecret: "my-client-secret",
  AccessToken: "my-access-token",
  RefreshToken: "my-refresh-token",
}

Usage

import (
  "fmt"
  "github.com/yanatan16/golang-soundcloud/soundcloud"
  "net/url"
)

func DoSomeSoundCloudApiStuff(accessToken string) {
  api := New("", accessToken)

  var myId string

  // Get yourself!
  if me, err := api.Me().Get(); err != nil {
    panic(err)
  } else {
    fmt.Printf("My userid is %s, username is %s, and I have %d followers\n", me.Id, me.Username, me.FollowerCount)
  }
}

Tests

To run the tests, you'll need at least a ClientId (which you can get from here), and preferably an authenticated users' AccessToken, which is a bit harder to get (involves authenticating for an app and getting that auth token)

First, fill in config_test.go.example and save it as config_test.go. Then run go test

Notes

  • Certain methods require an access token so check the official documentation before using an unauthenticated Api. This package will use it if it is given.

License

MIT-style. See LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].