Giter Club home page Giter Club logo

sdk-scala's Introduction

Ticketmaster API: Discovery Scala SDK

For more detailed information about the API and to get your API key head here. This SDK supports v2.

Create API client

import com.ticketmaster.api.discovery._

val api = DiscoveryApi("your-api-key")

API calls are non-blocking so ensure that there is a scala.concurrent.ExecutionContext implicitly available.

Making API calls

API calls all take a case class representing the criteria for that call. For example, search events takes a com.ticketmaster.api.discovery.SearchEventsRequest on which you can set your criteria.

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

val criteria = SearchEventsRequest(keyword = "coachella", size = 5)

val pendingResponse: Future[PageResponse[Events]] = api.searchEvents(criteria)

See docs for full list of criteria and resources they relate to.

Rate limit details are provided in every response in com.ticketmaster.api.discovery.RateLimits. Details include current rate limit per day, time for next rate limit reset, how many calls remain in current time period and how many calls over the rate limit. Also, API calls for searching will return a com.ticketmaster.api.discovery.Page as part of the result.

pendingResponse.map { response =>
    println(response.pageResult.result.events) // search results
    println(response.pageResult.page) // paging details
    println(response.rateLimits) // rate limits
  }

Error handling

This library piggy-backs on scala.concurrent.Future semantics for handling errors. Exceptions can be handled in the recover combinator.

Remaining work

  • Expose _links and _embedded for each resource.
  • Remove boilerplate code transforming criteria to http request, possibly via Shapeless.

Wish list

  • Allow pluggable http client.
  • Allow pluggable json parser.
  • Turn search results into a stream/iterator.

sdk-scala's People

Contributors

paulseddon 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.