- Notifications
You must be signed in to change notification settings - Fork10
A simple Command Line Interface that allows you to authenticate with the Pindo API.
License
pindoio/pindo-cli
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Install from PyPi usingpip, a package manager for Python.
pip install pindo-cli
Don't have pip installed? Try installing it, by running this from the command line:
$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
python setup.py install
You may need to run the above commands withsudo
.
Once you have installedPindo CLI you're ready to go.
pindo --help
Usage: pindo [OPTIONS] COMMAND [ARGS]...Pindo CLIA simple Command Line Interface that allows you to authenticate with the Pindo APIhttps://www.pindo.ioOptions: --debug / --no-debug -v, --version Show the version and exit. --help Show this message and exit.Commands: balance Get account balance org Organization refresh-token Refresh a Token. register Create a new Pindo account. sms Send atest message token Request a tokenfor using Pindo API.
- Send a test message
pindo sms --help
Usage: pindo sms [OPTIONS] Send atest messageOptions: --token TEXT API Token --to TEXT Receiver phone number (+250xxxxxx) --text TEXT Message to send --sender TEXT Sender name --help Show this message and exit.
Code | Text | Meaning |
---|---|---|
201 | sent | Successfully sent |
401 | unauthorized | unauthorized access |
404 | not found | invalid resource URI |
409 | conflict | number is from unsupported country |
409 | conflict | number is from unsupported telco |
409 | conflict | Wrong phone number format |
- An example of a successfully sent SMS.
{"bonus":0.0,"discount":0.4,"item_count":1,"item_price":0.006,"remaining_balance":71421.953,"self_url":"http://api.pindo.io/v1/sms/out_sms_01H7DJEJ1YZKTNT8EDXY2C7YG9","sms_id":"out_sms_01H7DJEJ1YZKTNT8EDXY2C7YG9","status":"sent","to":"+250789385878","total_cost":0.006}
- Pindo Delivery Report (DLR) Webhook Event example
POST
methods
{"status":"DELIVRD","sms_id":1058918,"modified_at":"24-07-2020, 23:35:32","retries_count":0}
Thepindo api
needs your Token. You can either pass the token directly to the constructor (see the code below) or via environment variables.
# cURL# Send a single smscurl -X POST \https://api.pindo.io/v1/sms/ \-H'Accept: */*' \-H'Authorization: Bearer your-token' \-H'Content-Type: application/json' \-d'{"to" : "+250781234567","text" : "Hello from Pindo","sender" : "Pindo"}'# Send bulk smscurl -X POST \https://api.pindo.io/v1/sms/bulk \-H'Accept: */*' \-H'Authorization: Bearer your-token' \-H'Content-Type: application/json' \-d'{"recipients" : [{"phonenumber": "+250781234567", "name": "Remy Muhire"}],"text" : "Hello @contact.name, Welcome to Pindo","sender" : "Pindo"}'
# pythonimportrequeststoken='your-token'headers= {'Authorization':'Bearer '+token}# For single smsdata= {'to' :'+250781234567','text' :'Hello from Pindo','sender' :'Pindo'}url='https://api.pindo.io/v1/sms/'# For bulk smsdata= {'recipients' : [{'phonenumber':'+250781234567','name':'Remy Muhire'}],'text' :'Hello @contact.name, Welcome to Pindo','sender' :'Pindo'}url='https://api.pindo.io/v1/sms/bulk'response=requests.post(url,json=data,headers=headers)print(response)print(response.json())
// NodeJSvarrequest=require("request");// For single smsdata={to:"+250781234567",text:"Hello from Pindo",sender:"Pindo"};url='https://api.pindo.io/v1/sms/'// For bulk smsdata={recipients:[{phonenumber:"+250781234567",name:"Remy Muhire"}],text:"Hello @contact.name, Welcome to Pindo",sender:"Pindo"};url='https://api.pindo.io/v1/sms/bulk'varoptions={method:"POST",body:data,json:true,url:url,headers:{Authorization:"Bearer your-token"}};functioncallback(error,response,body){if(!error&&response.statusCode==200){console.log(body);}}//call the requestrequest(options,callback);
// JavaOkHttpClientclient =newOkHttpClient();MediaTypemediaType =MediaType.parse("application/json");// For single smsRequestBodybody =RequestBody.create(mediaType,"{"to" : "+250781234567","text" : "HellofromPindo","sender" : "Pindo"}");Stringurl ="https://api.pindo.io/v1/sms/";// For bulk smsRequestBodybody =RequestBody.create(mediaType,"{"recipients": [{"phonenumber": "+250781234567","name": "RemyMuhire"}],"text":"Hello @contact.name, Welcome to Pindo","sender":"Pindo"}");String url = "https://api.pindo.io/v1/sms/bulk";Requestrequest =newRequest.Builder().url(url).post(body).addHeader("Content-Type","application/json").addHeader("Authorization","Bearer your-token").build();Responseresponse =client.newCall(request).execute();
// PHP$request =newHttpRequest();$request->setMethod(HTTP_METH_POST);$request->setHeaders(array('Authorization' =>'Bearer your-token','Content-Type' =>'application/json'));// For single sms$request->setUrl('https://api.pindo.io/v1/sms/');$request->setBody('{"to" : "+250781234567","text" : "Hello from Pindo","sender" : "Pindo"}');// For bulk sms$request->setUrl('https://api.pindo.io/v1/sms/bulk');$request->setBody('{ "recipients": [{"phonenumber": "+250781234567", "name": "Remy Muhire"}], "text": "Hello @contact.name, Welcome to Pindo", "sender": "Pindo"}');try {$response =$request->send();echo$response->getBody();}catch (HttpException$ex) {echo$ex;}// cURL$curl =curl_init();curl_setopt_array($curl,array(CURLOPT_URL =>"https://api.pindo.io/v1/sms/",CURLOPT_RETURNTRANSFER =>true,CURLOPT_ENCODING =>"",CURLOPT_MAXREDIRS =>10,CURLOPT_TIMEOUT =>0,CURLOPT_FOLLOWLOCATION =>true,CURLOPT_HTTP_VERSION =>CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST =>"POST",CURLOPT_POSTFIELDS =>"{\n\t\"to\" :\"+250781234567\",\n\t\"text\" :\"Test SMS.\",\n\t\"sender\" :\"Pindo\"\n}",CURLOPT_HTTPHEADER =>array("Authorization: Bearer token","Content-Type: application/json" ),));$response =curl_exec($curl);curl_close($curl);echo$response;
// GOpackage mainimport ("fmt""strings""net/http""io/ioutil")funcmain() {// For single smsurl:="https://api.pindo.io/v1/sms/"payload:= strings.NewReader("{"to" :"+250781234567","text" :"Hello from Pindo","sender" :"Pindo"}")// For bulk smsurl:="https://api.pindo.io/v1/sms/bulk"payload:= strings.NewReader("{"recipients" : [{"phonenumber":"+250781234567","name":"Remy Muhire"}],"text" :"Hello @contact.name, Welcome to Pindo","sender" :"Pindo"}")req,_:=http.NewRequest("POST",url,payload)req.Header.Add("Content-Type","application/json")req.Header.Add("Authorization","Bearer your-token")res,_:=http.DefaultClient.Do(req)deferres.Body.Close()body,_:=ioutil.ReadAll(res.Body)fmt.Println(res)fmt.Println(string(body))}
// C#varrequest=newRestRequest(Method.POST);request.AddHeader("Authorization","Bearer your-token");request.AddHeader("Content-Type","application/json");// For single smsrequest.AddParameter("undefined","{\n\t\"to\" :\"+250781234567\",\n\t\"text\" :\"Hello from Pindo\",\n\t\"sender\" :\"Pindo\"\n}",ParameterType.RequestBody);varclient=newRestClient("https://api.pindo.io/v1/sms/");// For bulk smsrequest.AddParameter("undefined","{\n\t\"recipients\": [{\"phonenumber\":\"+250781234567\",\"name\":\"Remy Muhire\"}],\n\t\"text\":\"Hello @contact.name, Welcome to Pindo\",\n\t\"sender\":\"Pindo\"\n}",ParameterType.RequestBody);varclient=newRestClient("https://api.pindo.io/v1/sms/bulk");IRestResponseresponse=client.Execute(request);
# rubyrequire'net/http'require'json'require'uri'# For single smsdata={to:'+250781234567',text:'Hello from Pindo',sender:'Pindo'};uri=URI('https://api.pindo.io/v1/sms/')# For bulk smsdata={recipients:[{phonenumber:'+250781234567',name:'Remy Muhire'}],text:'Hello @contact.name, Welcome to Pindo',sender:'Pindo'};uri=URI('https://api.pindo.io/v1/sms/bulk')http=Net::HTTP.new(uri.host,uri.port)req=Net::HTTP::Post.new(uri)req['Authorization']='Bearer your-token'req['Content-Type']='application/json'req.body=data.to_jsonhttp.request(req)
// Dartimport'dart:convert';import'package:http/http.dart'as http;Futuremain()async {// For single smsString url='https://api.pindo.io/v1/sms/';Map<String,String> data= {'to':'+250781234567','text':'Hello from Pindo','sender':'Pindo' };// For bulk smsString url='https://api.pindo.io/v1/sms/bulk';Map<String,String> data= {'recipients': [{'phonenumber':'+250781234567','name':'Remy Muhire'}],'text':'Hello @contact.name, Welcome to Pindo','sender':'Pindo' };Map<String,String> headers= {'Authorization':'Bearer your-token','Content-Type':'application/json' }; http.Response response=await http.post( url, body:jsonEncode(data), headers: headers, );print(response.statusCode);print(jsonDecode(response.body));}
Pindo Inbound messaging allows you to have two-way SMS communication. By quickly setting up a Webhook URL in Pindo's dashboard, you will receive any event on your configured short or long code.
- Pindo Inbound Webhook Event example
POST
methods
{"from":"+25078123456","to":"7878","created_at":"24-07-2020, 23:35:32","sms_id":1058918,"text":"Hello from Pindo","telco":"MTN"}
- List All Inbound SMS
{"inbound_sms":[ {"account_id":11783,"conversation_id":null,"created_at":"2022-08-05T12:32:42.196907","id":20,"id_smsc":null,"inbound_sms_number":"+250781113333","language_id":null,"telco_id":null,"text":"Hello world !" } ],"pages":{"first_url":"http://api.pindo.io/v1/sms/inbounds?page=1&per_page=20","last_url":"http://api.pindo.io/v1/sms/inbounds?page=1&per_page=20","next_url":null,"page":1,"pages":1,"per_page":20,"prev_url":null,"total":20 }}
PindoVerfiy
API lets you send a PIN to a user's phone and validate that they received it. PindoVerfiy can be used for a number of authentication and anti-fraud purposes, such as 2-factor authentication, password-less sign-in, and validating users’ phone numbers.
- An example of a successfully generated PIN.
{"message":"success","network":"63510","remaining_balance":487.49,"request_id":4}
- An example of a successfully verified PIN.
{ "message": "success", "remaining_balance": 487.49, "request_id": 4}
- Generate a PIN.
# pythonimportrequestsimportjsonurl="https://api.pindo.io/v1/sms/verify"payload=json.dumps({"brand":"Pindo","number":"+250781234567"})headers= {'Authorization':'Bearer your-token','Content-Type':'application/json'}response=requests.request("POST",url,headers=headers,data=payload)print(response.json())
// NodeJSvarrequest=require('request');varoptions={'method':'POST','url':'https://api.pindo.io/v1/sms/verify','headers':{'Authorization':'Bearer your-token','Content-Type':'application/json'},body:JSON.stringify({"brand":"Pindo","number":"+250781234567"})};request(options,function(error,response){if(error)thrownewError(error);console.log(response.body);});
// JavaOkHttpClientclient =newOkHttpClient().newBuilder() .build();MediaTypemediaType =MediaType.parse("application/json");RequestBodybody =RequestBody.create(mediaType,"{\n\"brand\":\"Pindo\",\n\"number\":\"+250781234567\"\n}\n");Requestrequest =newRequest.Builder() .url("https://api.pindo.io/v1/sms/verify") .method("POST",body) .addHeader("Authorization","Bearer your-token") .addHeader("Content-Type","application/json") .build();Responseresponse =client.newCall(request).execute();
// PHP<?php$curl =curl_init();curl_setopt_array($curl,array(CURLOPT_URL =>'https://api.pindo.io/v1/sms/verify',CURLOPT_RETURNTRANSFER =>true,CURLOPT_ENCODING =>'',CURLOPT_MAXREDIRS =>10,CURLOPT_TIMEOUT =>0,CURLOPT_FOLLOWLOCATION =>true,CURLOPT_HTTP_VERSION =>CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST =>'POST',CURLOPT_POSTFIELDS =>'{ "brand":"Pindo", "number":"+250781234567"}',CURLOPT_HTTPHEADER =>array('Authorization: Bearer your-token','Content-Type: application/json' ),));$response =curl_exec($curl);curl_close($curl);echo$response;
- Verify a PIN
// NodeJSvarrequest=require('request');varoptions={'method':'POST','url':'https://api.pindo.io/v1/sms/verify/check','headers':{'Authorization':'Bearer your-token','Content-Type':'application/json'},body:JSON.stringify({"code":"752623","request_id":4})};request(options,function(error,response){if(error)thrownewError(error);console.log(response.body);});
- Check PIN status
// NodeJSvarrequest=require('request');varoptions={'method':'GET','url':'https://api.pindo.io/v1/sms/verify/status/:request_id','headers':{'Authorization':'Bearer your-token'}};request(options,function(error,response){if(error)thrownewError(error);console.log(response.body);});
- Cancel a PIN
// NodeJSvarrequest=require('request');varoptions={'method':'PUT','url':'https://api.pindo.io/v1/sms/verify/cancel/:request_id','headers':{'Authorization':'Bearer your-token'}};request(options,function(error,response){if(error)thrownewError(error);console.log(response.body);});
About
A simple Command Line Interface that allows you to authenticate with the Pindo API.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.