Clarifai library for Go

Overview

Clarifai Golang Library

Library for our v1 API.

GoDoc

Disclaimer

This API client only supports Clarifai v1 API. Stay tuned for the v2 support.

Usage

go get github.com/clarifai/clarifai-go

package main

import (
	"fmt"

	"github.com/clarifai/clarifai-go"
)

func main() {
	client := clarifai.NewClient("<client_id>", "<client_secret>")
	// Get the current status of things
	info, err := client.Info()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%+v\n", info)
	}
	// Let's get some context about these images
	urls := []string{"https://samples.clarifai.com/metro-north.jpg", "https://samples.clarifai.com/puppy.jpeg"}
	// Give it to Clarifai to run their magic
	tag_data, err := client.Tag(clarifai.TagRequest{URLs: urls})

	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%+v\n", tag_data) // See what we got!
	}

	feedback_data, err := client.Feedback(clarifai.FeedbackForm{
		URLs:    urls,
		AddTags: []string{"cat", "animal"},
	})

	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%+v\n", feedback_data)
	}
}

Testing

Run go test

##Special Thanks

Thanks so much to Sam Couch for his amazing contribution to the Clarifai client libraries by starting this one and graciously handing it off to us. Follow him on Twitter @SamuelCouch.

Comments
  • Add support for color endpoint and file uploads.

    Add support for color endpoint and file uploads.

    This PR does a few things.

    • Adds file upload support for tag/color endpoints.
    • Adds full support for the color endpoint via the Color() method.
    • Adds tests to verify color support.
    • Updates README.md to show examples of new functionality.
    opened by zquestz 3
  • Use JSON for tag and feedback requests.

    Use JSON for tag and feedback requests.

    I switched tag and feedback requests to use JSON rather than form data. (The API supports both.) This simplifies request construction and makes it easier to add more request parameters later.

    This is a breaking change for the Tag function, but it should help avoid more breaking changes in the future.

    opened by solongordon 2
  • Update README example code to use working image URLs

    Update README example code to use working image URLs

    I was trying out the library and was surprised to discover that the URLs in the README example are broken (I'm guessing you guys changed where you hosted them somewhat recently). When I tried running the code from the example I got a somewhat vague error, with no indication that the URLs just weren't pointing to images.

    In any case, I thought I'd update the docs to use working image URLs.

    opened by skewart 0
  • Failed to unmarshal response for image request

    Failed to unmarshal response for image request

    When trying to get metadata about the following image, the API throws errors.

    https://data.whicdn.com/images/25997864/large.gif

    cannot unmarshal array into Go value of type string
    
    opened by zquestz 0
  • added color tagging support

    added color tagging support

    This is a pretty simple addition. Just added support for color tagging requests, surprised it was not in the client initially.

    Let me know if you need any changes made before merging this in.

    opened by devinmcgloin 0
  • Request language

    Request language

    I am trying to add possibility to specify language for each request.

    I tried just adding a Language string variable to the TagRequest struct, but that didn't seem to do it.

    Any suggestions?

    opened by filecamp 0
  • Images and Videos tag response inconsistency

    Images and Videos tag response inconsistency

    This pull request adds ImageTag() and VideoTag() methods and parallel model structures for image and video tag response. The existing Tag() method will return the same structure (but now the struct is named ImageTag).

    The problem is explained here: https://github.com/Clarifai/clarifai-go/issues/10

    opened by tkrajina 0
  • Images and Videos tag response inconsistency

    Images and Videos tag response inconsistency

    I have some problems with this library when getting tags for videos. The problem is this:

    This is an example response from the tag endpoint for a .mp4 video:

    {
        "results": [
            {
                "result": {
                        "classes": [
                            [
                                "no person",
                                "indoors",
    

    And this is a response for an image:

    {
        "results": [
            {
                "result": {
                    "tag": {
                        "classes": [
                            "keyboard",
    

    The classes field is an array of strings for images, but an array of an array of strings for videos.

    This is the diff which fixes the video responses:

    diff --git a/requests.go b/requests.go
    index 22fdb06..96bb70b 100644
    --- a/requests.go
    +++ b/requests.go
    @@ -56,9 +56,9 @@ type TagResult struct {
            LocalID       string   `json:"local_id"`
            Result        struct {
                    Tag struct {
    -                       Classes []string  `json:"classes"`
    +                       Classes [][]string  `json:"classes"`
                            CatIDs  []string  `json:"catids"`
    -                       Probs   []float32 `json:"probs"`
    +                       Probs   [][]float32 `json:"probs"`
                    }
            }
            DocIDString string `json:"docid_str"`
    

    But this will break the image tag response.

    opened by tkrajina 0
  • Implement a tag function from local file system

    Implement a tag function from local file system

    according to the documentation here you are able to make requests to the tag parameter with a local file, but this functionallity is not availble in this client. it seems to be implemented in the python client here. i'll be willing to put in a pull request.

    opened by faiq 2
Releases(v1.2.0)
Owner
Clarifai
Clarifai
A Go client library for the Twitter 1.1 API

Anaconda Anaconda is a simple, transparent Go package for accessing version 1.1 of the Twitter API. Successful API queries return native Go structs th

Aditya Mukerjee 1.1k Sep 27, 2022
Go library for http://www.brewerydb.com/ API

brewerydb brewerydb is a Go library for accessing the BreweryDB API usage import "github.com/naegelejd/brewerydb" Construct a new Client using your Br

Joseph Naegele 19 Sep 27, 2022
Go(lang) client library for Cachet (open source status page system).

cachet Go(lang) client library for Cachet (open source status page system). Features Full API support Components Incidents Metrics Subscribers Various

Andy Grunwald 90 Jan 28, 2022
Go library for interacting with CircleCI

go-circleci Go library for interacting with CircleCI's API. Supports all current API endpoints allowing you do do things like: Query for recent builds

Jesse Szwedko 65 Sep 27, 2022
Go library for accessing the Codeship API v2

Codeship API v2 Client for Go Codeship API v2 client for Go. Documentation https://godoc.org/github.com/codeship/codeship-go Usage go get -u github.co

CodeShip 18 Nov 15, 2021
Go client library for interacting with Coinpaprika's API

Coinpaprika API Go Client Usage This library provides convenient way to use coinpaprika.com API in Go. Coinpaprika delivers full market data to the wo

Coinpaprika 15 Aug 8, 2022
Go library to access geocoding and reverse geocoding APIs

GeoService in Go Code Coverage A geocoding service developed in Go's way, idiomatic and elegant, not just in golang. This product is designed to open

Jerry Zhao 440 Sep 6, 2022
Go library for accessing the GitHub API

go-github go-github is a Go client library for accessing the GitHub API v3. Currently, go-github requires Go version 1.9 or greater. go-github tracks

Google 8.8k Sep 24, 2022
Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://developer.github.com/v4/).

githubv4 Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql). If you're looking for a client

null 918 Sep 20, 2022
Go library to use the imgur.com API

go-imgur Go library to use the imgur.com API. At the moment only the anonymous part of the API is supported, but that is used in a production environm

null 23 Jul 17, 2022
Go client library for Atlassian Jira

go-jira Go client library for Atlassian Jira. Features Authentication (HTTP Basic, OAuth, Session Cookie) Create and retrieve issues Create and retrie

Andy Grunwald 1.2k Sep 21, 2022
A GO API library for working with Marathon

Go-Marathon Go-marathon is a API library for working with Marathon. It currently supports Application and group deployment Helper filters for pulling

Rohith Jayawardene 197 Sep 27, 2022
Go library for accessing the MyAnimeList API: http://myanimelist.net/modules.php?go=api

go-myanimelist go-myanimelist is a Go client library for accessing the MyAnimeList API. Project Status The MyAnimeList API has been stable for years a

Stratos Neiros 31 May 10, 2022
Go library for accessing trending repositories and developers at Github.

go-trending A package to retrieve trending repositories and developers from Github written in golang. This package were inspired by rochefort/git-tren

Andy Grunwald 121 Aug 2, 2022
a Go (Golang) MusicBrainz WS2 client library - work in progress

gomusicbrainz a Go (Golang) MusicBrainz WS2 client library - a work in progress. Current state Currently GoMusicBrainz provides methods to perform sea

Michael Wendland 47 Sep 15, 2022
GoStorm is a Go library that implements the communications protocol required to write Storm spouts and Bolts in Go that communicate with the Storm shells.

gostorm godocs GoStorm is a Go library that implements the communications protocol required for non-Java languages to communicate as part of a storm t

John Gilmore 129 Sep 27, 2022
This project implements a Go client library for the Hipchat API.

Hipchat This project implements a Go client library for the Hipchat API (API version 2 is not supported). Pull requests are welcome as the API is limi

Andrew Bonventre 104 Jan 12, 2022
Go(lang) client library for accessing information of an Apache Mesos cluster.

megos Go(lang) client library for accessing an Apache Mesos cluster. Features Determine the Mesos leader Get the current state of every mesos node (ma

Andy Grunwald 55 Sep 27, 2022
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)

simples3 : Simple no frills AWS S3 Library using REST with V4 Signing Overview SimpleS3 is a golang library for uploading and deleting objects on S3 b

Rohan Verma 92 Sep 7, 2022