Minimal Dart wrapper to interact with Some Random Api. Easy to use, simplified and lightweight.

Overview

SRA - Some Random Api

CI Pub Package

Minimal Dart wrapper to interact with Some Random Api. Easy to use, simplified and lightweight.

Getting started

Add the package to your project.

$ dart pub add sra

Usage

Import the package to your file/project.

import 'package:sra/sra.dart' as sra;

The package exports a base Client class which is the central spot for interacting with the api. The client class itself has only one public method fetch.

import 'package:sra/sra.dart' show Client;

void main() async {
    var client = Client();
    // Optionally pass the api key on class initiation
    // Example: Client(apiKey);
    var res = await client.fetch('/animal/dog');
    print(res);
}

The fetch method takes 1 mandatory argument of type String, the endpoint path. You can optionally pass query parameters to the function (if the endpoint requires so). For endpoints that have some required parameters, if you don't specify one of them, the function throws an error.

// Fetching with parameters
client.fetch('/canvas/misc/oogway', {
    'quote': 'Nothing is a mistake'
});
// The endpoint doesn't need any parameters so we don't
// need to provide anything else
client.fetch('/animal/dog');
// This throws an error, because the lied endpoint
// requires a mandatory parameter called 'avatar' which
// is not specified here, so it'll throw an error.
client.fetch('/canvas/misc/lied', {
    'username': 'Yakiyo'
});

The fetch method returns Object which can be one of the two types, a Map<String, String> or List<int>. Endpoints that return a json result return Map, while endpoints that return PNG images return a List<U8int> or a buffer that can be used to write to a file (see fetch_binary.dart). Detailed usages can be found in the example/ directory. Feel free to ping me (Yakiyo#1206) in the SRA Discord Server for help, questions or anything.

All valid endpoints and their required/optional arguments are availabale in SRA docs. Currently only the Rank Card, Welcome Image (premium) and Welcome Image (free) are unavailable in the package. To be added soon ™️ .

Contribution and Issues

For any issues or bugs, please file a new issue here.

All contributions are welcome. Before creating a Pull Request or working on a new feature, please open up an issue so that it can be discussed.

Author

sra.dart © Yakiyo. Authored and maintained by Yakiyo.

Released under MIT License

You might also like...

Simple library for generating random ascii strings

random_string Simple library for generating random ascii strings. Design goals and limitations While this package provides randomBetween for convenien

Nov 19, 2022

Some examples for how to build dart code using package:analyzer and package:code_builder only (i.e. no build_runner or build.yaml files)

What is this? Some examples for how to build dart code from another dart code us

Apr 17, 2022

Scribble is a lightweight library for freehand drawing in Flutter supporting pressure, variable line width and more!

Scribble is a lightweight library for freehand drawing in Flutter supporting pressure, variable line width and more!

Scribble Scribble is a lightweight library for freehand drawing in Flutter supporting pressure, variable line width and more! A

Dec 16, 2022

A Dart testing utility for asserting that some code emits a compilation error.

A Dart testing utility for asserting that some code emits a compilation error.

Dec 11, 2022

Parser builder - Lightweight template-based parser build system. Simple prototyping. Comfortable debugging. Effective developing

parser_builder Lightweight template-based parser build system. Simple prototypin

Dec 1, 2022

Easy to use cross-platform regex replace command line util

replace Easy to use cross-platform regex replace command line util. Can't remember the arguments to the find command? or how xargs works? Maybe sed is

Feb 1, 2022

This library contains methods that make it easy to consume Mpesa Api.

This library contains methods that make it easy to consume Mpesa Api. It's multi-platform, and supports CLI, server, mobile, desktop, and the browser.

Dec 15, 2021

A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

Oct 26, 2022
Releases(0.1.0)
Owner
Yakiyo
Hi im a 17 yr old highschooler. I read light novels, mangas and watch animes. Currently learning Flutter
Yakiyo
Easy to use session wrapper that adds support to session storage and management in flutter.

flutter_session_manager Adds an easy to use wrapper to session management in flutter. Allows for easy session storage and management. The session pers

Eduardo Migueis 2 Feb 15, 2022
A simple flexible API wrapper for coinbase commerce API. Totally unofficial.

coinbase_commerce A dart library that connects to interact with the Coinbase Commerce API. Enables projects to connect seamlessly to coinbase and rece

Onuoha Obinna 3 Oct 17, 2021
Volt is a wrapper over the Revolt API for easily writing bots using the Dart language.

Volt is a wrapper over the Revolt API for easily writing bots using the Dart language. It is currently in active development so not all of the functionality has yet been implemented.

null 8 Dec 13, 2022
Dart package for random strings and numbers, with weights

randomness Dart package for random strings and numbers, with weights Random strings, numbers. RNG with weights. Cryptographically secure options. Gett

null 2 Aug 6, 2022
An alternative random library for Dart.

Randt Randt library for Dart... Description Use Randt to get a random integer from a list, generate random integer in a specific range and generate ra

Bangladesh Coding Soldierz 3 Nov 21, 2021
Generate random data(string, integer, IPs etc...) using Dart.

Generate random data using Features API provides generation of: Integers in any range of numbers Strings with various characters and length Colors rep

Dinko Pehar 14 Apr 17, 2022
Dart wrapper via dart:ffi for https://github.com/libusb/libusb

libusb Dart wrapper via dart:ffi for https://github.com/libusb/libusb Environment Windows(10) macOS Linux(Ubuntu 18.04 LTS) Usage Checkout example Fea

Woodemi Co., Ltd 28 Dec 20, 2022
Flutter Cool Random User Generate 🔥🔥

Flutter Cool Random User Generate ????

Hmida 8 Sep 10, 2022
apps random

flutter_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Tajul Aulia Muda 1 Oct 21, 2021
Random color generator for Flutter

Random color generator Pub link: https://pub.dartlang.org/packages/random_color This library will generate random colors that are visually pleasing an

Luka Knezic 56 Jun 13, 2022