Giter Club home page Giter Club logo

objects-go's Introduction

objects-go

Segment objects client for Go. For additional documentation view the godocs. For documentation about our Go analytics library, visit here.

Description

Segment’s Objects API allows you to send stateful business objects right to Redshift and other Segment supported data warehouses. These objects can be anything that is relevant to your business: products in your product catalogs, partners on your platform, articles on your blog, etc.

The Objects API lets you set custom objects in your own data warehouse.

// First call to Set
Client.Set(&objects.Object{
  ID: "room1000",
  Collection: "rooms"
  Properties: map[string]interface{}{
    "name": "Charming Beach Room Facing Ocean",
    "location": "Lihue, HI",
    "review_count": 47,
})

// Second call on the same object 
Client.Set(*objects.Object{
  ID: "room1000",
  Collection: "rooms"
  Properties: map[string]interface{}{
    "owner": "Calvin",
    "public_listing": true,
})

// Make sure objects are flushed before your main goroutine exits
Client.Close()

This call makes the objects available in your data warehouse…

select id, name, location, review_count, owner, public_listing from hotel.rooms

..which will return…

'room1000' | 'Charming Beach Room Facing Ocean' | 'Lihue, HI' | 47 | "Calvin" | true

All objects will be flattened using the go-tableize library. Objects API doesn't allow nested objects, empty objects, and only allows strings, numeric types or booleans as values.

HTTP API

There is a single .set HTTP API endpoint that you'll use to send data to Segment.

POST https://objects.segment.com/v1/set

with the following payload:

{
  "collection": "rooms",
  "objects": [
    {
      "id": "2561341",
      "properties": {
        "name": "Charming Beach Room Facing Ocean",
        "location": "Lihue, HI",
        "review_count": 47
      }
    }, {
      "id": "2561342",
      "properties": {
        "name": "College town feel — plenty of bars nearby",
        "location": "Austin, TX",
        "review_count": 32
      }
    }
  ]
}

Here’s a curl example of how to get started:

curl https://objects.segment.com/v1/set \
   -u PROJECT_WRITE_KEY: \
   -H 'Content-Type: application/json' \
   -X POST -d '{"collection":"rooms","objects":[{"id": "2561341","properties": {"name": "Charming Beach Room Facing Ocean","location":"Lihue, HI","review_count":47}}]}'

License

MIT

objects-go's People

Contributors

f2prateek avatar liquidy avatar n2parko avatar vincepri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.