Getting started

Getting started

Structure of the code

One of the ideas behind Skybrud.Social is that the implementation for a given service/API consists of two parts - a client part that quickly described is responsible for making the actual requests to the API and handling the necessary authentication, while a service part is responsible for parsing and handling the responses for the client in a manner that makes it easier for you to use.

As an example, the Instagram implementation has a class named InstagramService, which will be your entry point for communicating with the Instagram API. The InstagramService class will internally use the InstagramOAuthClient class for making requests to the API.

The service is typically not a 1:1 implementation of the API, so if there is something I haven't implemented, you can also use the InstagramOAuthClient class directly. The InstagramOAuthClient class is also used for authentication - eg. obtaining an access token on behalf of your users.

Both the client and service parts are divided into multiple endpoints - eg. for Instagram, the InstagramService class will have a Users endpoint of the type InstagramUsersEndpoint, while the InstagramOAuthClient similarly will have a Users endpoint of the type InstagramUsersRawEndpoint.

Making calls to the API

Again using the Instagram API as an example, we could make a request to get information about a user.

For the service part, the code for getting information about my Instagram user would look something like:

InstagramUserResponse response = service.Users.GetUser(189413627);

InstagramUser user = response.Body.Data;


When making a request to the API using the GetUser method, you will get an instance of InstagramUserResponse back representing the entire response.

The Body property of the response will return an object roughly mapping the properties of the JSON value received from the API:

  "meta": {
    "code": 200
  "data": {
    "username": "abjerner",
    "bio": "",
    "website": "",
    "profile_picture": "",
    "full_name": "Anders Bjerner",
    "counts": {
      "media": 22,
      "followed_by": 25,
      "follows": 30
    "id": "189413627"

For the client part, a similar call would look like the example below. The Body matches the response body received from the API, which for Instagram is in the format of JSON.

SocialHttpResponse response = service.Client.Users.GetUser("189413627");

string json = response.Body;