Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

How to use the API ?

Skid edited this page May 19, 2019 · 17 revisions

It is really simple.

and also, no rate limits but remain cool :)

Every request will return a json output.

If you want C++ for example : https://rcgp.anjara.eu/api/image/cpp

cpp

Raw API is not implemented in the revamp yet :P

## If json isn't your thing and you want a picture directly, you can use the raw api.

* If you want a random picture from all languages, just call https://rcgp.anjara.eu/raw.php
* If you need a specific language, you can check the list of languages by calling https://rcgp.anjara.eu/api/?listlanguages
* And with that you can specify the language you want by calling https://rcgp.anjara.eu/raw.php?language=

If you want JavaScript for example : https://rcgp.anjara.eu/raw.php?language=js

_Note : You can use this as src for an `<img>` tag also !_

![js](https://rcgp.anjara.eu/raw.php?language=js)

Enjoy :D

Issues that we are already aware of.

The "NodeJS is crap" case

In NodeJS, the auto negociation process for ECC curve is crap, so if you try to use the api with NodeJS, generally it will return a magnificent error.

To solve this problem (unless NodeJS developpers fix this stupid issue) you need to specify the curve to use.

Here is an exemple of how to do it.

// I totally disapprove what that thing up says -- leonekmi
const https = require('https');

req = https.request({
	hostname: 'rcgp.anjara.eu',
	port: 443,
	path: '/api/image',
	method: 'GET',
	ecdhCurve: 'X25519' // Or any other curve supported by the webserver.
}, (res) => {
	var data;

	res.on('data', (d) => {
		data = data + d;
	});

	res.on('end', () => {
		var json = JSON.parse(data);
		// do something here
	});
});
req.end();
Clone this wiki locally