You are viewing a single comment's thread from:

RE: Releasing fpl 0.5.0

in #fpl6 years ago (edited)

Hi @amosbastian, thanks for sharing this post which is helping me to learn some Python.

In regards to the performance issue, GraphQL might come to the rescue to run one single query instead of a few -- it may have a positive impact on the API's performance which seems to be using a REST paradigm.

"""
The FPL module.
Fantasy Premier League API:
* /bootstrap-static
* /bootstrap-dynamic
* /elements
* /element-summary/{player_id}
* /entry/{user_id}
* /entry/{user_id}/cup
* /entry/{user_id}/event/{event_id}/picks
* /entry/{user_id}/history
* /entry/{user_id}/transfers
* /events
* /event/{event_id}/live
* /fixtures/?event={event_id}
* /game-settings
* /leagues-classic-standings/{league_id}
* /leagues-classic-standings/{league_id}
* /leagues-entries-and-h2h-matches/league/{league_id}
* /leagues-h2h-standings/{league_id}
* /my-team/{user_id}
* /teams
* /transfers
"""

Sort:  

The API itself isn't mine, but the Premier League's - fpl is just a wrapper around it. I was thinking more along the lines of creating a function that saves the players to a database locally, but I'm not sure that how I can implement that and if that would work on every single operating system.

On the other hand, I was thinking that in general terms we shouldn't struggle too much when it comes to retrieve data from a REST API, and I like REST by the way :)

Since I like REST too, in my humble opinion, that could be seen as kind of code smell in a sense that the API's architecture is not very well designed?

So, here are alternative scenarios (for PHP) to solve the problem of a slow REST API that requires too many operations to fetch the data:

  1. Write your own API with REST improving the architecture of the original one -- I tried to do something similar to fpl at Data Driven Test Development Demo

  2. Write your own API with GraphSQL -- GraphQL Demo for Symfony 4

In both cases, we're assuming that the API interface can be changed, and also it is okay to "scrap" and store the data on our side.

That's definitely something I will look into, thanks!

That makes sense. IMO, I'd suggest to implement a simple solution while observing if the results obtained are okay. What about REST API caching with HTTP headers? https://restfulapi.net/caching/

Coin Marketplace

STEEM 0.20
TRX 0.12
JST 0.029
BTC 61153.73
ETH 3403.85
USDT 1.00
SBD 2.51