#osrs #old #api-client #api-bindings #man #wise #wom

wom_rs

A rust api wrapper for the OSRS Wise Old Man API

1 unstable release

0.1.0 Feb 1, 2024

#399 in HTTP client

MIT license

89KB
2.5K SLoC

wom_rs

A asynchronous rust wrapper for interacting with Wise Old Man API.

The goal of wom_rs is to provide a 1:1 in rust to their API. This is still a work in progress and can find below in Endpoints Progress the current status of the endpoints. If you do find any issues or have any suggestions please feel free to open an issue.

Getting Started

add wom_rs to your Cargo.toml file:

[dependencies]
wom_rs = "0.1.0"

To get a client for interacting with the API, use the WomClient struct:

use wom_rs::WomClient;

//Default client
let wom_client = WomClient::new();

//Client with an api key
let api_key = std::env::var("WOM_API_KEY").unwrap();
let wom_client = WomClient::new_with_key(api_key);

Example Web Call

use wom_rs::WomClient;
let wom_client = WomClient::new();

let details = wom_client.player_client.get_details("IFat Fingers".to_string()).await;
println!("{:?}", details);

Endpoints Progress

Some may have cross over completion. For example you can get player name changes by username, but cannot submit request for a name change.

Project Layout

Clients

Contains the clients for interacting with the API. Each of the above endpoints will have a client accessed from WomClient.

Models

Various models used to represent the data returned from the API. You will find that many of the responses handled in models are very similar to each other. In the WOM API many responses are built off of each other. I did not find a good way to do this in rust. So I kept them separate for clarity.

Some of the models that may not be clear are:

  • error: Holds models for error responses from the API.
  • snapshot: Holds models for the snapshot data returned from the API. This mimics very closely to PlayerGain but kept separate for clarity.

Mock Responses

Contains the mock responses for the tests. These are used to test the deserialization of the responses from the API. All examples are either from the real API or the examples provided in WOM fantastic API documentation.

Special Thanks

None of this would be possible with out the wonderful team at Wise Old Man. Would not need a wrapper if it was not for their fantastic website. Not to mention their amazing documentation made creating this a breeze.

Dependencies

~6–18MB
~244K SLoC