Code Monkey home page Code Monkey logo

riot-cpp's Introduction

Welcome to Riot-cpp

ci build

Simple Api client for the Riot Games Resful API implemented in C++ 20.

This library implements rate limiting to prevent api key blacklisting from exceeding Riot's rate limits. The library handles server response error's and will retry when a successful request is possible (429, 500, 503 errors). The client contains a logging class to help with debugging dependent code as well as providing information of the running of the client. Riot-cpp will adapt to the specific api key's rate limits after the first request and try to recover from errors.

Riot-cpp uses libcurl to send https get requests. The Json parser simdjson is used as a dependency for testing but NOT in the library. Parsing is done by the user.

Documentation is located at following page.

view - Documentation

Basic Usage

Below demonstrates a request to Match V5 endpoint using PUUID with optional arguements. All endpoints return a unique pointer to a vector of chars. Dependency on Jsoncpp or an individual Json library was remoed to allow the user to decide how they wanted to parse json, allows flexibility for users if performance is a key concern for large responses.

#include "path/to/client.h"

using json_ptr = std::unique_ptr<std::vector<char>>

int main() {
    
    client::RiotApiClient example_client("<path/to/api/key>", "<path/to/logging/file>", logging::LEVEL::<level>, <bool verbose>);

    json_ptr response = example_client.Match.by_puuid("routing", "puuid", {"startTime", <user_arg>}, {"endTime", <user_arg>}, ...);
}

Including your API Key

It is highly recommended not to included api keys in source code as one may unintentionally share source coded publically with the api key exposed.

Riot-cpp accepts a path to a json file to extract your api key. The file should be of the following format.

{
    "api-key" : "<API KEY>"
}

Techincally, as long as "RGAPI-..." is anywhere in the file the client will find it.

Installation

Currently the repository must be cloned or downloaded via the releases.

git clone git+https://github.com/Dan-Tan/riot-cpp.git

Git submodules are highly recommended for use as a project dependency.

git submodule add git+https://github.com/Dan-Tan/riot-cpp.git

Option 1: CMake

Linking to executable or library

add_subdirectory(<path/to/riot-cpp/src>)
target_include_directories(<your library or executable> <PRIVATE/PUBLIC> <path/to/riot-cpp/src/riot-cpp>)
target_link_libraries(<your library or executable> <PRIVATE/PUBLIC> riot-cpp)

Option 2: Manually with libriot-cpp.

The shared object file is located as "riot-cpp/build/src/riot-cpp/libriot-cpp.so" and can be manually linked with your compiler of choice. You must include the following in your includes

#include "path/to/riot-cpp/src/client/client.h"

See options for linking with gcc, Options for Linking

Disclaimer

Riot-cpp is not developed by or affiliated with Riot Games.

riot-cpp's People

Contributors

dan-tan avatar ianwong1999 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ianwong1999

riot-cpp's Issues

Query Dependency Structure

Develop query dependencies, that take arguments from previous queries to allow for high level requests.

Missing cstring header in client.cpp

I tried compiling in local and it shows that string header is missing in client.cpp

/home/ian/code/riot-cpp/src/client/client.cpp: In function ‘size_t client::WriteCallBack_header(void*, size_t, size_t, void*)’:
/home/ian/code/riot-cpp/src/client/client.cpp:76:38: error: ‘strlen’ was not declared in this scope
   76 |         if (colon_ind == new_chars + strlen(new_chars)) {
      |                                      ^~~~~~
/home/ian/code/riot-cpp/src/client/client.cpp:13:1: note: ‘strlen’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
   12 | #include "client.h"
  +++ |+#include <cstring>
   13 |
/home/ian/code/riot-cpp/src/client/client.cpp:86:74: error: ‘strlen’ was not declared in this scope
   86 |         new_buffer->insert(new_buffer->end(), &colon_ind[2], new_chars + strlen(new_chars) - 1);
      |                                                                          ^~~~~~
/home/ian/code/riot-cpp/src/client/client.cpp:86:74: note: ‘strlen’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?

Change Endpoint query structure

Currently, endpoints are chosen by passing string arguements to the RiotApiClient::query() method. This is quite stupid of me as it removes the possibility of compile time errors with endpoint names, so querying non-existent endpoints will throw an invalid arguement runtime error which is not terrible but objectively worse.

Add endpoints such that they are function calls, is the main goal (try reduce boiler code thouhgh).

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.