Coder Social home page Coder Social logo

go-india / zomato Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 51 KB

Go client library for accessing Zomato API :fork_and_knife: :curry: :beers:

License: Other

Go 98.76% Makefile 1.24%
zomato zomato-api zomato-api-wrapper restaurants restaurant-api go-client

zomato's Introduction

zomato

GoDoc Build Status Coverage Status Report card

zomato is a Go client library for accessing Zomato API.

Zomato APIs give you access to the freshest and most exhaustive information for over 1.5 million restaurants across 10,000 cities globally. Power your content with the most exhaustive curated restaurant information.

Installation

Requires Go version 1.7 or above.

$ go get -u github.com/go-india/zomato

Usage

Construct a new zomato client, then use the various methods on the client to access different parts of the Zomato API.

For demonstration:

package main

import (
  "context"
  "github.com/go-india/zomato"
)

var ctx = context.Background()

func main() {
  client := zomato.NewClient(API_KEY)

  // Gets restaurant details.
  res, err := client.Restaurant(ctx, 463)

  // Search for restaurants.
  restaurants, err := c.Search(ctx, zomato.SearchReq{
    Query: "delhi",
    Radius: 200,
  })

  // Gets reviews of the restaurant.
  reviews, err := c.Reviews(ctx, zomato.ReviewsReq{
    RestaurantID: 463,
    Count:        100,
  })
}

Notes

  • Using the context package for passing context.
  • Make sure you have a valid API Key. If not, you can get a new one by registering at Zomato Developers Portal.

For complete usage of zomato, see the full package docs.

Authentication

If you are using concrete Client, then you need to assign client.Auth field to make the client methods use authenticator for requests.

client := zomato.Client{
  Auth: zomato.NewAuth(API_KEY),
}

This will add API Key to each request made by client methods.

Integration Tests

You can run integration tests from the directory.

$ go test -v

Note Use -update flag to update the testdata. When using update flag, you will need to define ZOMATO_TEST_API_KEY in your environment for tests to use the API Key for testing.

Contributing

We welcome pull requests, bug fixes and issue reports. Before proposing a change, please discuss your change by raising an issue.

License

This library is distributed under the MIT license found in the LICENSE file.

Author

Yash Raj Singh

zomato's People

Contributors

iamyashrs avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zomato's Issues

Separate Request/Response Objects

Right now, the library is built as a system build on both concrete request/response objects. Helpers combine the both of them into one.

But since the request/response objects are building blocks of the helpers, we can separate them out into 2 new sub-packages inside the repo. This will give us a clear usage and better docs.

import (
    "github.com/go-india/zomato/req"
    "github.com/go-india/zomato/resp"
    "github.com/go-india/zomato"
)

The client and its helpers are the ultimate API/Usage of this library.
Other types and objects are building blocks of that.

Swagger: Generated Client

We provide basic tools to generate a Go client for Zomato using their swagger.json file. But we don't provide the generated client for now.

The reason for this is, it can be generated easily using the make tool we have provided in the /swagger directory.

Should we give a generated client library inside /swagger directory?

Docs: Examples

We can add more examples for godoc and README, using func Example* methods.

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.