Skip to main content

Automatically generate api client libraries/sdk for websites, online services and 3rd party private api.

Project description

What is Rapic ?

Rapic is a simple and fast lightweight tool for automatically generating api client libraries and sdk for websites and online services. It also support automatic generation of client libraries for 3rd party public and private api's which is very good for reverse engineers.

Installation

pip install rapic

Running

There are 2 ways to use rapic

  • Using rapic-client-generator to automatically generate client file from a reverse engineering tool.
  • Manually creating rapic api client file.

Using Rapic Client Generator

As a reverse engineer saving time is essential which means reducing time spent on writing api client for reversed private 3rd party api, website or other internet services. Rapic makes generating client libraries easy with just these few steps :

** NOTE** Rapic automatic client generator only support BURPSUITE reverse engineering tool currently

  • STEP 1 : While using BurpSuite Right click on a website under site map tab under target

  • STEP 2 : Save requests as xml file and untick base64 encode requests and response

  • STEP 3 : Run 'rapic-client-generator burp <website_site_or_api_name> saved_file.xml'

  • STEP 4 : Open generated json file and name your request then Use the client like

       from rapic.client import APIClient
       api = ApiClient(client_name='website_or_service_name', request_file=generated_file_from_rapic.json)
       val = api.get_currency() # A request is named get_currency by changing request_<num> to get_currency for a chosen request in json file
    

Using Rapic Client JSON files

Programmers can also save time when creating client libraries/sdk for their website and service using rapic. Simply by creating a json file with structure

***json_file.json  

            {
             "host": "httpbin.org",
              "scheme": "http",
                  "get_my_ip": {
                        "path": "/ip",
                        "method": "GET"
                    },
             }
                
                
 *** client.py
 
      from rapic.client import APIClient
      api = ApiClient(client_name='website_or_service_name', request_file=json_file.json)
      val = api.get_my_ip() 

NOTE : check test folder for more json file structure and supported keys

Request can also be hooked before its sent to server to do extra processing like http signature signing, timestamp generation etc.

    ***json_file.json 
    
            {
             "host": "httpbin.org",
              "scheme": "http",
                  "get_user_followers": {
                        "path": "/get_user_followers/{path_id}",
                        "method": "POST"
                    },
             }
     ***client.py
     
        import hashlib
        from rapic.client import APIClient
        from rapic.hook import APIClientHook
        
        class MyApiClient(APIClient):

            @APIClientHook.hook_client_request_data(client='httpbin',
                                                    requests=['get_user_followers'])
            def set_http_signature_on_header(data, **kwargs):
                sign_request = data['url'] + data['method'] + urlencode(data['body_data'])
                m = hashlib.sha256()
                m.update(bytes(sign_request, encoding='utf8'))
                signature = m.hexdigest()
                data['headers']['signature'] = signature
                self.http_signature = signature
                return data
        api = MyApiClient(client_name='website_or_service_name', request_file=json_file.json)
        val = api.get_user_followers(data={user_id : 67888}, url_data={path_id : 'unique_id_get_set_as_path_id'})

** List of hooks supported **

  • APIClientHook.hook_client_prepared_request()
  • APIClientHook.hook_client_response()
  • APIClientHook.hook_client_request_data()
  • APIClientHook.hook_client_body_data()
  • APIClientHook.hook_client_url()
  • APIClientHook.hook_client_header()

LICENSE

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rapic-0.1.5.tar.gz (17.5 kB view details)

Uploaded Source

File details

Details for the file rapic-0.1.5.tar.gz.

File metadata

  • Download URL: rapic-0.1.5.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8

File hashes

Hashes for rapic-0.1.5.tar.gz
Algorithm Hash digest
SHA256 fff054261af69b24a55484b08717d9fd1319999c3bbd22ab448abbea889d43ca
MD5 155c1d953972a82a6c61f0aa6dc6bebd
BLAKE2b-256 add45e663da92d0515b3b65a02e9f201a1f6225a57932bd1c4635560d10e8f9c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page