Login Register




Tutorial Lilith API Walkthorough filter_list
Author
Message
Lilith API Walkthorough #1
Yay, more tools! And a hostname to boot!

Anyway, it's 4 AM again, and I just finished the first few patches on my API server, so I thought I'd do a runthrough of how it all works.

If you've looked at the project page (link in my sig), you'll have seen that there are two ways of using Lilith: POST and Query Strings. POST requests will become more important when I add any kind of file management API, so We'll go over the Query String option first.

Query Strings, as a refresher, are the text following a question mark in a url. This text usually represents input values for html forms, but can be parsed to a hash table with PHP, which is what I did.

To get a response from Lilith with a Query, it's just the following few lines with python:
Code:
from requests import get

print get('http://lilithapi.red?action=<action>[&args=[args]]).text
Or just one with curl:
Code:
curl 'http://lilithapi.red?action=<action>[&args=[args]]'

An example of what to use could be 'ip', which doesn't take arguments, or 'gw-ip', which would take a domain name, ie 'sinister.ly', as it's parameter.

You can also choose which output format you want from either json (which is the default), plain text, or j-box, from J Language. You can access these by passing the rtype parameter in your Query.
Code:
#json
$ curl 'http://lilithapi.red?action=ip'
{"ip": "0.0.0.0"}

#text
$ curl 'http://lilithapi.red?action=ip&rtype=text'
ip | 0.0.0.0

#jbox
$ curl 'http://lilithapi.red?action=ip&rtype=jbox'
+----+---------+
| ip | 0.0.0.0 |
+----+---------+


For the POSTing side of things, using RESTful APIs can get really confusing in some languages, so I'm just going to stick with python.

Basic ip request:
Code:
from requests import post

print post(url='http://lilithapi.red',files={'action': 'ip'}).text

More complex DNS resolution with jbox return type:
Code:
from requests import post

print post(
    url='http://lilithapi.red', #base url
    files={                     #start of parameters
        'action': 'gw-ip',      #equivilant to ?action=gw-ip
        'args': 'sinister.ly',  #args=sinister.ly
        'rtype': 'jbox'         #rtype=jbox
    }
).text                          #get the text from the page


Sorry this wasn't super informative, I should be waking up in 2 hours, so I'm kinda tired. Anyway, enjoy, and feel free to check out the project.

EDIT: POST requests are fucked in python, so just stick with Query Strings.
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply




Messages In This Thread
Lilith API Walkthorough - by Inori - 01-05-2016, 10:40 AM



Users browsing this thread: 1 Guest(s)