DEV Community

Victor Avelar
Victor Avelar

Posted on

Episode 5 - Adding resources to your Client

So after being at the Alps for some days, here we go again.

What is a resource?

According to a resource is described as follows:

The fundamental concept in any RESTful API is the resource. A resource is an object with a type, associated data, relationships to other resources, and a set of methods that operate on it. It is similar to an object instance in an object-oriented programming language, with the important difference that only a few standard methods are defined for the resource (corresponding to the standard HTTP GET, POST, PUT and DELETE methods), while an object instance typically has many methods.

This means that when adding a resource this will allow us to perform operations with our client on specific and well defined types.

How to add a resource to a client?

  1. We create a resource type to hold the methods to interact with articles, this will contain a pointer to our devto.Client implementation,
// articles.go

type ArticleResource struct{
    API *Client // this will receive a pointer to your client instance
Enter fullscreen mode Exit fullscreen mode

And then we attach this using the client constructor

you can see a working example in the repository

GitHub logo VictorAvelar / devto-api-go

A go client for the API


A go client for the API

License: MIT

Travis CI

Build Status


Scrutinizer Build Status Scrutinizer Code Quality Code Coverage

Go ecosystem

Go Report Card GoDoc


  • Base client and configuration
  • Articles resource
  • CLI utility
  • Authentication resource
  • Extend the tests suite
  • Provide code examples


This library is not an official API library, but a friendly contribution to the community

From now on, we are up for the wtfutil part.

Top comments (0)