https://github.com/dustinsmith1024/my_sports_feeds
API wrapper for My Sports Feeds. https://www.mysportsfeeds.com
https://github.com/dustinsmith1024/my_sports_feeds
elixir mlb nba nfl nhl sports
Last synced: 3 months ago
JSON representation
API wrapper for My Sports Feeds. https://www.mysportsfeeds.com
- Host: GitHub
- URL: https://github.com/dustinsmith1024/my_sports_feeds
- Owner: dustinsmith1024
- Created: 2017-04-07T21:06:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-15T01:31:02.000Z (almost 6 years ago)
- Last Synced: 2024-04-14T14:14:54.028Z (about 1 year ago)
- Topics: elixir, mlb, nba, nfl, nhl, sports
- Language: Elixir
- Homepage:
- Size: 229 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# My Sports Feeds
A HTTP wrapper for the [My Sports Feeds API](https://www.mysportsfeeds.com/data-feeds/api-docs)
Provides a caching layer out of the box as well.
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `my_sports_feeds` to your list of dependencies in `mix.exs`:```elixir
def deps do
[{:my_sports_feeds, "~> 2.0.0"}]
end
```## Running
You will need an account with My Sports Feeds, api key in the `MY_SPORTS_FEEDS_API_KEY` environments variable.
```elixir
▶ MY_SPORTS_FEEDS_API_KEY="" iex -S mix
```Or put it in config.
```elixir
config :msf, api_key: System.get_env("MY_SPORTS_FEEDS_API_KEY")
```Make an API call
```elixir
iex(18)> {:ok, %{body: body}} = MSF.NFL.player_gamelogs(date: "20190120", player: "tyreek-hill", season: "2019-playoffs")14:37:48.184 [info] GET /nfl/2019-playoffs/player_gamelogs.json -> 200 (582.446 ms)
...
{:ok,
%{
body: %{
"gamelogs" => [
%{
"game" => %{
"awayTeamAbbreviation" => "NE",
"homeTeamAbbreviation" => "KC",
"id" => 51289,
"startTime" => "2019-01-20T23:40:00.000Z",
"week" => 20
},
"player" => %{
"firstName" => "Tyreek",
"id" => 9910,
"jerseyNumber" => 10,
"lastName" => "Hill",
"position" => "WR"
},
"stats" => %{iex(17)> hd(body["gamelogs"])["stats"]["receiving"]
%{
"rec1stDowns" => 1,
"rec20Plus" => 1,
"rec40Plus" => 1,
"recAverage" => 42.0,
"recFumbles" => 0,
"recLng" => 42,
"recTD" => 0,
"recYards" => 42,
"receptions" => 1,
"targets" => 3
}
```NBA example:
```
iex(7)> {:ok, %{body: body}} = MSF.NBA.player_gamelogs(player: "kevin-durant", season: "2018-2019-regular")
14:49:41.035 [info] GET /nba/2018-2019-regular/player_gamelogs.json -> 200 (5046.794 ms)
...
iex(6)> hd(body["gamelogs"])["stats"]["offense"]
%{"ast" => 6, "astPerGame" => 6.0, "pts" => 27, "ptsPerGame" => 27.0}
```Force a API update by passing `force: true` to the options.
```elixir
iex(15)> MSF.NFL.player_gamelogs(date: "20190120", player: "tyreek-hill", season: "2019-playoffs", force: true)
```