Difference between revisions of "Integration:api"

From PrometheusIPN Wiki
Jump to: navigation, search
(Created page with "====== The API ====== ===== What is this api? ===== An API(Application Program Interface), is a way of communication with a system both internally and externally. With Prometh...")
 
 
(29 intermediate revisions by 4 users not shown)
Line 1: Line 1:
====== The API ======
+
<div style="background-color: #FF0000; color: #000000; width: 100%; padding: 10px; margin-bottom: 10px;"><i class="fa fa-exclamation-triangle"></i> Please note that our API is currently very limited.</div>
===== What is this api? =====
+
<div style="background-color: #1fa67a; color: #fff; width: 100%; padding: 10px;"><i class="fa fa-info-circle"></i> This page is recommended only for <strong>advanced users</strong>. If you don't have any familiarity with PHP or APIs, consider getting a developer to look this over for you. Support is <b>not provided</b> with the API.</div>
An API(Application Program Interface), is a way of communication with a system both internally and externally. With Prometheus this allows you to do the following things currently:
+
<br>
 +
===WHAT IS THIS API? WHAT DOES IT DO?===
 +
An API (short for "Application Program Interface"), is a way of communication with a system both internally and externally. It allows you to perform actions or receive data from/to a system. Prometheus uses an API to allow you to perform various actions using a script remotely.
  
Add a package to a user(Using Steam64 or SteamID)
+
===WHAT CAN I DO WITH THE API?===
Get donation goal info
+
With Prometheus, you can do the following things currently:
  
 +
* Add a package to a user(Using Steam64 or SteamID)
 +
* Get donation goal info
 +
 +
===API VARIABLES===
 
The API has a few things you can designate:
 
The API has a few things you can designate:
  
''hash'' - The hash you generate above if you enable API. This has to be kept a secret. Do not give it to anyone else.
+
*''hash'' - The hash is the API key you created when enabling the API from your Prometheus admin dashboard. This has to be kept a secret. Do not give it to anyone else.
  
''action'' - The performed action
+
*''action'' - The performed action
  
''steamid'' - The users steamid
+
*''steamid'' - The users steamid
  
''package'' - The package
+
*''package'' - The package
  
 
===== How do I use it? =====
 
===== How do I use it? =====
 
The API is accessed by typing this into your browser:
 
The API is accessed by typing this into your browser:
  
''http://yourprometheus.com/api.php?hash=HASH&action=ACTION''
+
<code>http://yourprometheuswebsiteurl.com/api.php?hash=HASH&action=ACTION</code>
  
 
Not all actions require a hash, for instance the getGoal action does not require a hash and can be accessed directly. The API returns the response in **JSON**. It can be securely communicated with using **cURL**.
 
Not all actions require a hash, for instance the getGoal action does not require a hash and can be accessed directly. The API returns the response in **JSON**. It can be securely communicated with using **cURL**.
Line 25: Line 31:
 
===== List of actions =====  
 
===== List of actions =====  
  
^ Action         ^ Hash ^ Properties         ^ Returns ^
+
{| class="wikitable"
| getGoal        | No  | None               | error, cur, total, goal   |
+
|+Api calls
| assignPackage  | Yes  | steamid, package    | error, msg               |
+
|-
| addCredits      | Yes  | steamid, amount    | error, msg                |
+
!Action
 +
!getGoal
 +
!assignPackage
 +
!addCredits
 +
!getPackages
 +
|-
 +
!Hash
 +
|No
 +
|Yes
 +
|Yes
 +
|Yes
 +
|-
 +
!Properties
 +
|None
 +
|steamid, package
 +
|steamid, amount
 +
|None
 +
|-
 +
!Returns
 +
|error, cur, total, goal
 +
|error, msg
 +
|error, msg
 +
|error, packages
 +
|}
  
 
===== Examples =====
 
===== Examples =====
 
==== getGoal Example ====
 
==== getGoal Example ====
  
<file php getGoalExample.php>
+
'''getGoalExample.php'''
<?php
+
  <?php
 
   
 
   
         $get = file_get_contents('http://marcuz.eu/ipn/api.php?action=getGoal');
+
         $get = file_get_contents('http://yourprometheuswebsiteurl.com/api.php?action=getGoal');
 
         $array = json_decode($get, true);
 
         $array = json_decode($get, true);
 
        
 
        
Line 52: Line 81:
 
         }
 
         }
 
   
 
   
?>
+
  ?>
</file>
 
  
 
==== assignPackage Example ====
 
==== assignPackage Example ====
  
<file php assignPackageExample.php>
+
'''assignPackageExample.php'''
<?php
+
  <?php
 
   
 
   
 
         // Replace everything in uppercase letters with your own information
 
         // Replace everything in uppercase letters with your own information
         $source = 'http://yourprometheus.com/api.php?hash=YOUR_HASH&action=assignPackage&package=PACKAGE_ID&steamid=STEAM64_OR_STEAMID';
+
         $source = 'http://yourprometheuswebsiteurl.com/api.php?hash=YOUR_HASH&action=assignPackage&package=PACKAGE_ID&steamid=STEAM64_OR_STEAMID';
 
   
 
   
 
         $ch = curl_init();
 
         $ch = curl_init();
Line 89: Line 117:
 
         }
 
         }
 
   
 
   
?>
+
  ?>
</file>
 

Latest revision as of 19:36, 18 July 2017

Please note that our API is currently very limited.
This page is recommended only for advanced users. If you don't have any familiarity with PHP or APIs, consider getting a developer to look this over for you. Support is not provided with the API.


WHAT IS THIS API? WHAT DOES IT DO?

An API (short for "Application Program Interface"), is a way of communication with a system both internally and externally. It allows you to perform actions or receive data from/to a system. Prometheus uses an API to allow you to perform various actions using a script remotely.

WHAT CAN I DO WITH THE API?

With Prometheus, you can do the following things currently:

  • Add a package to a user(Using Steam64 or SteamID)
  • Get donation goal info

API VARIABLES

The API has a few things you can designate:

  • hash - The hash is the API key you created when enabling the API from your Prometheus admin dashboard. This has to be kept a secret. Do not give it to anyone else.
  • action - The performed action
  • steamid - The users steamid
  • package - The package
How do I use it?

The API is accessed by typing this into your browser:

http://yourprometheuswebsiteurl.com/api.php?hash=HASH&action=ACTION

Not all actions require a hash, for instance the getGoal action does not require a hash and can be accessed directly. The API returns the response in **JSON**. It can be securely communicated with using **cURL**.

List of actions
Api calls
Action getGoal assignPackage addCredits getPackages
Hash No Yes Yes Yes
Properties None steamid, package steamid, amount None
Returns error, cur, total, goal error, msg error, msg error, packages
Examples

getGoal Example

getGoalExample.php

 <?php

       $get = file_get_contents('http://yourprometheuswebsiteurl.com/api.php?action=getGoal');
       $array = json_decode($get, true);
      
       if($array['error'] == 0){
               $percentage = $array['perc'];
               $total = $array['total'];
               $goal = $array['goal'];
               $currency = $array['cur'];
              
               echo '
                      Goal: '.$goal.' '.$currency.'
Received: '.$total.' '.$currency.'
Percentage: '.$percentage.'% '; }  ?>

assignPackage Example

assignPackageExample.php

 <?php

       // Replace everything in uppercase letters with your own information
       $source = 'http://yourprometheuswebsiteurl.com/api.php?hash=YOUR_HASH&action=assignPackage&package=PACKAGE_ID&steamid=STEAM64_OR_STEAMID';

       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, $source);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($ch, CURLOPT_SSLVERSION,4);
       $data = curl_exec($ch);
       $error = curl_error($ch);
       curl_close ($ch);
              
       if($data === false) {
               // Display an error if there is any
               die('Curl error: ' . $error);
       }
      
       // Decode the data response
       $array = json_decode($data, true);
      
       // Display an error if there is any
       if($array['error'] == 1){
               die($array['msg']);
       }
      
       // Display success message
       if($array['error'] == 0){
               echo($array['msg']);
       }

 ?>