The sport scraper API for XtraPoints in collaboration with IBM & Kitura
Accessing the API.
The base url of the scraper is
There are four routes that are available:
historical-schedule route returns a basic schedule that contains the teams that played, their final scores, the date of the game and the game status. The
live-schedule returns a more granular schedule that includes team records, and scores for each quarter. The
curent route returns what is the current season and week for a given league. The
mock-data route returns a mock schedule for different time periods to simulate progression.
Let's explain what each path parameter means:
leagueType: Represents the desired sports league. Currently only supports the NFL. For this, pass
year: Represents the season in
leagueType. When using
live-schedule, the minimum value that can be passed is
2001. When using
historical-schedule, the minimum value that can be passed is
week: Represents the week in
year. For the NFL, the value provided should be
timePeriod: Represents the period in time to use. The value provided should be between
0defines the beginning of the week. All games have not started yet.
1defines the moddle of the week. Some games have completed but not all of them.
2represents the end of the week. All games will be completed and have a game status of either
Requirements For Installing Locally
- Xcode 8.3.*
- Swift 3.1.*
- Swift Package Manager
If you would like to run the API in a Linux environment, we recommend using Docker for running containers. Setting up Docker is simple
- Download the Docker Community Edition For Mac at https://store.docker.com/search?type=edition&offering=community.
- In a terminal, Install IBM's Swift Docker image by doing
$ docker pull ibmcom/swift-ubuntu.
- Then, install the CouchBD Docker image with admin support by doing
$ docker pull couchdb.
You will need the system libraries for parsing XML or HTML install on your machine or you will receive an error when compling.
- Using Homebrew, install libxml2 with
$ brew install libxml2.
- Then run
$ brew link --force libxml2.
Now that Docker has been setup, we can now begin setting up the repo on our local machine.
- In a terminal, do
$ git clone firstname.lastname@example.org:silverlogic/PicksApp-SportsScrapper.git.
- Go to the root of the clone repo by doing
$ cd PicksApp-SportsScrapper.
- Now we need to build the dependencies by doing
$ swift build.
- To generate the
xcodeprojfile to open the project in Xcode, do
$ swift package generate-xcodeproj.
- To open the project in Xcode, do
$ open SportsScraper.xcodeproj.
Running The Server On Your Machine.
- When running the server locally, the base url will be
- The database admin can be accessed at
Running The Server In OSX
When running the server on your local machine using OSX, you first need to start up the database. You can do that in a terminal by doing
$ docker run --name couchdb -p 5984:5984 -e COUCHDB_USER="admin" -e COUCHDB_PASSWORD="password" couchdb when running the database for the very first time. This will start CouchDB. By default, an admin user will be set for you. If you then want to run the database again, you would do
$ docker start couchdb. Then to stop it, do
$ docker stop couchdb. To start the database and enabling logging, do
$ docker start couchdb -a. Once the database is running, in Xcode, switch the scheme to
SportsScraperServer. Then do
CMD R on the keyboard to run the server.
Running The Server In Linux
When implementing new features, you want to make sure that the implementation also works in a Linux environment, since the Foundation APIs that you would use in a Cloud Foundary application aren't fully avaliable. To test in Linux locally on your machine, access your terminal and do
$ docker-compose up. This will start CouchDB as well as the server.
Running Tests In OSX
- First, run the database. Refer to section
Running The Server in OSXin the README on how to do that.
- Then in Xcode, on the keyboard, do
Running Tests In Linux
- To run in Linux locally in your machine, access your terminal and do
$ docker-compose -f docker-test.yml up. This will start CouchDB as well as start running tests.
Here is a roadmap of features that we will like to implement overtime:
- Add granualar data to
- Caching of all past schedules
- Travis CI setup
- Implement a test suite with database interactions once caching is implemented
- Require authentication for accessing routes