NAV Navigation
CurlPHPPythonC#GONodeJava

Onurix API v1.0.0

Desplácese hacia abajo para ver ejemplos de código, solicitudes de ejemplo y respuestas. Seleccione un idioma para las muestras de código de las pestañas de arriba o del menú de navegación móvil.

Aqui se describe el API -REST a fin de enviar mensajes de texto por medio de la plataforma https://www.onurix.com, para utilizarlos usted previamente debe haber permitido la IP del servidor donde se va a ejecutar el script que va a consumir el API, el key key y codigo de client client siempre debe enviarse en cada petición, para realizar la configuracion de la IP y consultar estos parametros ingrese a su cuenta menu Seguridad.

Base URLs:

Email: Support

Balance

Consulta el numero disponible de creditos de una cuenta

URL

Obtiene el balance de una cuenta

Code samples

# También puede usar wget
curl -X GET https://www.onurix.com/api/v1/messages-state?client=AQUI_SU_CLIENT&key=AQUI_SU_KEY
# Ejecutar: composer require guzzlehttp/guzzle:*
<?php

require'vendor/autoload.php';

$headers=array(
'Content-Type'=>'application/x-www-form-urlencoded',
'Accept'=>'application/json',
);

$client=new\GuzzleHttp\Client(
);

try{
$response=$client->request('GET','https://www.onurix.com/api/v1/balance?client=AQUI_SU_CLIENT&key=AQUI_SU_KEY',
array(
'headers'=>$headers,
)
);
print_r($response->getBody()->getContents());
}
catch(\GuzzleHttp\Exception\BadResponseException$e){
// Manejar excepciones o errores de API
print_r($e->getMessage());
}

// ...
import requests
headers ={
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json'
}

r = requests.get('https://www.onurix.com/api/v1/balance?client=AQUI_SU_CLIENT&key=AQUI_SU_KEY', headers = headers)

print(r.json())
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Net.Http;
usingSystem.Net.Http.Headers;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingNewtonsoft.Json;

/// <<summary>>
/// Ejemplo de Http Client
/// <</summary>>
publicclassHttpExample
{
privateHttpClient Client {get;set;}

/// <<summary>>
/// Configurar http client
/// <</summary>>
publicHttpExample()
{
Client = new HttpClient();
}

/// Hacer una solicitud
public async Task MakeGetRequest()
{
string url ="https://www.onurix.com/api/v1/balance?client=AQUI_SU_CLIENT&key=AQUI_SU_KEY";
var result = await GetAsync(url);
}

/// Realiza una solicitud GET
public async Task GetAsync(string url)
{
//Iniciar la solicitud
HttpResponseMessage response =await Client.GetAsync(url);

//Validar resultado
response.EnsureSuccessStatusCode();

//Contenido de la petición
response.Content.ReadAsStringAsync();

}

}
package main

import(
"fmt"
"strings"
"net/http"
"io/ioutil"
"io/ioutil"
)

funcmain(){

headers :=map[string][]string{
"Content-Type":[]string{"application/x-www-form-urlencoded"},
"Accept":[]string{"application/json"},
}

req, err := http.NewRequest("GET","https://www.onurix.com/api/v1/balance?client=AQUI_SU_CLIENT&key=AQUI_SU_KEY", nil)
req.Header = headers

client :=&http.Client{}
resp, err := client.Do(req)

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)

if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
// Ejecutar: npm install request --save
var requests = require("request");

var options = {
method: 'GET',
url: 'https://www.onurix.com/api/v1/balance?key=AQUI_SU_KEY&client=AQUI_SU_CLIENT',
headers:{ 'content-type': 'application/x-www-form-urlencoded' },
};
var test = requests(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});



URL obj =newURL("https://www.onurix.com/api/v1/balance?client=AQUI_SU_CLIENT&key=AQUI_SU_KEY");
HttpURLConnection con =(HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("charset","utf-8");
int responseCode = con.getResponseCode();
BufferedReader in =newBufferedReader(
newInputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response =newStringBuffer();
while((inputLine = in.readLine())!=null){
response.append(inputLine);
}
in.close();
System.out.println(response.toString());

GET /balance

Body parameter

client:0
key: stringstri

Parameters

NameInTypeRequiredDescription
bodybodyobjecttruenone
» clientbodyinteger(int64)trueEl Id del cliente
» keybodystringtrueKey de la cuenta Onurix

Example responses

200 Response

{
"status":0
}

Responses

StatusMeaningDescriptionSchema
200OKOperación exitosaResponseBalance
520UnknownParametros invalidosErrorResponseBalance

URLShort

Crea una URL corta a partir de una URL Larga

URL

Crea una URL corta a partir de una URL larga

Code samples

# También puede usar wget
curl -X POST https://www.onurix.com/api/v1/url/short
-d key="AQUI_SU_KEY" -d client="AQUI_SU_CLIENT"
-d name="AQUI_NOMBE_DE_URL" -d url-long="AQUI_URL_LARGA"\
-H 'Content-Type: application/x-www-form-urlencoded'\
-H 'Accept: application/json'
# Ejecutar: composer require guzzlehttp/guzzle:*
<?php

require'vendor/autoload.php';

$headers=array(
'Content-Type'=>'application/x-www-form-urlencoded',
'Accept'=>'application/json',
);

$client=new\GuzzleHttp\Client();

// Define la matriz del cuerpo de la solicitud.
$request_body = array(
"client"=>"AQUI_SU_CLIENT",
"key"=>"AQUI_SU_KEY",
"name"=>"AQUI_NOMBE_DE_URL",
"url-long"=>"AQUI_URL_LARGA",
);

try{
$response=$client->request('POST','https://www.onurix.com/api/v1/url/short',array(
'headers'=>$headers,
'form_params'=>$request_body,
)
);
print_r($response->getBody()->getContents());
}
catch(\GuzzleHttp\Exception\BadResponseException$e){
// Manejar excepciones o errores de API
print_r($e->getMessage());
}

// ...
import requests
headers ={
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json'
}

data = {
'client':'AQUI_SU_CLIENT',
'key':'AQUI_SU_KEY',
'name':'AQUI_NOMBE_DE_URL',
'url-long':'AQUI_URL_LARGA'
}

r = requests.post('https://www.onurix.com/api/v1/url/short', headers = headers, data = data)

print(r.json())
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Net.Http;
usingSystem.Net.Http.Headers;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingNewtonsoft.Json;

/// <<summary>>
/// Ejemplo de Http Client
/// <</summary>>
publicclassHttpExample
{
privateHttpClient Client {get;set;}

/// <<summary>>
/// Configurar http client
/// <</summary>>
publicHttpExample()
{
Client = new HttpClient();
}


/// Hacer una solicitud
public async Task MakePostRequest()
{
string url ="https://www.onurix.com/api/v1/url/short";

var dict = new Dictionary<string, string>();
dict.Add("client", "AQUI_SU_CLIENT");
dict.Add("key", "AQUI_SU_KEY");
dict.Add("name", "AQUI_NOMBE_DE_URL");
dict.Add("url-long", "AQUI_URL_LARGA");


await PostAsync( url,dict);

}

/// Realiza una solicitud POST
public async Task PostAsync( string url , Dictionary<string, string> dict )
{
// Ejecutar método post
HttpResponseMessage response =await Client.PostAsync(url, new FormUrlEncodedContent(dict));
// contenido de la petición
var contents = await response.Content.ReadAsStringAsync();
}

package main

import(
"fmt"
"strings"
"net/http"
"io/ioutil"
)

funcmain(){

headers :=map[string][]string{
"Content-Type":[]string{"application/x-www-form-urlencoded"},
"Accept":[]string{"application/json"},
}

data := strings.NewReader("client=AQUI_SU_CLIENT&key=AQUI_SU_KEY&name=AQUI_NOMBE_DE_URL&name=AQUI_NOMBE_DE_URL&url-longAQUI_URL_LARGA")
req, err := http.NewRequest("POST","https://www.onurix.com/api/v1/url/short", data)
req.Header = headers

client :=&http.Client{}
resp, err := client.Do(req)

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))

}
// Ejecutar: npm install request --save
var requests = require("request");

var options = {
method: 'POST',
url: 'https://www.onurix.com/api/v1/url/short',
headers: { 'content-type': 'application/x-www-form-urlencoded'},
formData: {
key:'AQUI_SU_KEY',
client:'AQUI_SU_CLIENT',
name:'AQUI_NOMBE_DE_URL',
url-long:'AQUI_URL_LARGA'
}
};

var test = requests(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});


String urlParameters = "key=AQUI_SU_KEY&client=AQUI_SU_CLIENT&name=AQUI_NOMBE_DE_URL&url-long=AQUI_URL_LARGA";
URL obj =newURL("https://www.onurix.com/api/v1/url/short");
HttpURLConnection con =(HttpURLConnection) obj.openConnection();
con.setDoOutput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("charset", "utf-8");

OutputStream outputStream = con.getOutputStream();
outputStream.write(urlParameters.getBytes());
outputStream.flush();
outputStream.close();
int responseCode = con.getResponseCode();
BufferedReader in =newBufferedReader(
newInputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response =newStringBuffer();
while((inputLine = in.readLine())!=null){
response.append(inputLine);
}
in.close();
System.out.println(response.toString());

POST /url/short

Body parameter

client:0
key: string
name: string
url-long: string
alias: string
is-premium:true
group-name: string
domain-name: string
expiration-time-statistics: string

Parameters

NameInTypeRequiredDescription
bodybodyobjecttruenone
» clientbodyinteger(int64)trueEl Id del cliente
» keybodystringtrueKey de la cuenta Onurix
» namebodystringtrueNombre de la URL
» url-longbodystringtrueURL Larga
» aliasbodystringfalseAlias para la URL corta
» is-premiumbodybooleanfalseEs premium por defecto falso
» group-namebodystringfalseGrupo al que se desea asociar
» domain-namebodystringfalseDominio al que se desea asociar
» expiration-time-statisticsbodystringfalseExpiración de la URL en meses valores por defecto enviar 0

Example responses

200 Response

{
"urlShort":"string",
"urlLong":"string",
"msg":"string"
}

Responses

StatusMeaningDescriptionSchema
200OKRespuesta exitosa de la operacionResponseURLShort
520UnknownParametros invalidosErrorResponse

URLStatistics

Devuelve estadísticas de la URL a partir de su nombre

URL

Obtiene los clicks de una URL corta

Code samples

# También puede usar wget
curl -X POST https://www.onurix.com/api/v1/url/short-statistic
-d key="AQUI_SU_KEY" -d client="AQUI_SU_CLIENT"
-d name-url="AQUI_NOMBE_DE_URL" -d since="Fecha inicial YYYY-MM-DD"
-d until="Fecha final YYYY-MM-DD"\
-H 'Content-Type: application/x-www-form-urlencoded'\
-H 'Accept: application/json'
# Ejecutar: composer require guzzlehttp/guzzle:*
<?php

require'vendor/autoload.php';

$headers=array(
'Content-Type'=>'application/x-www-form-urlencoded',
'Accept'=>'application/json',
);

$client=new\GuzzleHttp\Client();

// Define la matriz del cuerpo de la solicitud.
$request_body = array(
"client"=>"AQUI_SU_CLIENT",
"key"=>"AQUI_SU_KEY",
"name-url"=>"AQUI_NOMBE_DE_URL",
"since"=>"Fecha inicial YYYY-MM-DD",
"until"=>"Fecha final YYYY-MM-DD");

try{
$response=$client->request('POST','https://www.onurix.com/api/v1/url/short-statistic',array(
'headers'=>$headers,
'form_params'=>$request_body,
)
);
print_r($response->getBody()->getContents());
}
catch(\GuzzleHttp\Exception\BadResponseException$e){
// Manejar excepciones o errores de API
print_r($e->getMessage());
}

// ...
import requests
headers ={
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json'
}

data = {
'client':'AQUI_SU_CLIENT',
'key':'AQUI_SU_KEY',
'name-url':'AQUI_NOMBE_DE_URL',
'since':'Fecha inicial YYYY-MM-DD',
'until':'Fecha final YYYY-MM-DD'
}

r = requests.post('https://www.onurix.com/api/v1/url/short-statistic', headers = headers, data = data)

print(r.json())
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Net.Http;
usingSystem.Net.Http.Headers;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingNewtonsoft.Json;

/// <<summary>>
/// Ejemplo de Http Client
/// <</summary>>
publicclassHttpExample
{
privateHttpClient Client {get;set;}

/// <<summary>>
/// Configurar http client
/// <</summary>>
publicHttpExample()
{
Client = new HttpClient();
}


/// Hacer una solicitud
public async Task MakePostRequest()
{
string url ="https://www.onurix.com/api/v1/url/short-statistic";

var dict = new Dictionary<string, string>();
dict.Add("client", "AQUI_SU_CLIENT");
dict.Add("key", "AQUI_SU_KEY");
dict.Add("name-url", "AQUI_NOMBE_DE_URL");
dict.Add("since", "Fecha inicial YYYY-MM-DD");
dict.Add("until", "Fecha final YYYY-MM-DD");


await PostAsync( url,dict);

}

/// Realiza una solicitud POST
public async Task PostAsync( string url , Dictionary<string, string> dict )
{
// Ejecutar método post
HttpResponseMessage response =await Client.PostAsync(url, new FormUrlEncodedContent(dict));
// contenido de la petición
var contents = await response.Content.ReadAsStringAsync();
}

package main

import(
"fmt"
"strings"
"net/http"
"io/ioutil"
)

funcmain(){

headers :=map[string][]string{
"Content-Type":[]string{"application/x-www-form-urlencoded"},
"Accept":[]string{"application/json"},
}

data := strings.NewReader("client=AQUI_SU_CLIENT&key=AQUI_SU_KEY&phone=AQUI_EL_NUMERO_DE_CELULAR&name-url=AQUI_NOMBE_DE_URL&since=Fecha inicial YYYY-MM-DD&until=Fecha final YYYY-MM-DD")
req, err := http.NewRequest("POST","https://www.onurix.com/api/v1/url/short-statistic", data)
req.Header = headers

client :=&http.Client{}
resp, err := client.Do(req)

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))

}
// Ejecutar: npm install request --save
var requests = require("request");

var options = {
method: 'POST',
url: 'https://www.onurix.com/api/v1/url/short-statistic',
headers: { 'content-type': 'application/x-www-form-urlencoded'},
formData: {
key:'AQUI_SU_KEY',
client:'AQUI_SU_CLIENT',
name-url:'AQUI_NOMBE_DE_URL',
since:'Fecha inicial YYYY-MM-DD',
until:'Fecha final YYYY-MM-DD'
}
};

var test = requests(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});


String urlParameters = "key=AQUI_SU_KEY&client=AQUI_SU_CLIENT&name-url=AQUI_NOMBE_DE_URL&since=Fecha inicial YYYY-MM-DD&until=Fecha final YYYY-MM-DD";
URL obj =newURL("https://www.onurix.com/api/v1/url/short-statistic");
HttpURLConnection con =(HttpURLConnection) obj.openConnection();
con.setDoOutput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("charset", "utf-8");

OutputStream outputStream = con.getOutputStream();
outputStream.write(urlParameters.getBytes());
outputStream.flush();
outputStream.close();
int responseCode = con.getResponseCode();
BufferedReader in =newBufferedReader(
newInputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response =newStringBuffer();
while((inputLine = in.readLine())!=null){
response.append(inputLine);
}
in.close();
System.out.println(response.toString());

POST /url/short-statistic

Body parameter

client:0
key: string
name-url: string
since: string
until: string
category: string

Parameters

NameInTypeRequiredDescription
bodybodyobjecttruenone
» clientbodyinteger(int64)trueEl Id del cliente
» keybodystringtrueKey de la cuenta Onurix
» name-urlbodystringtrueNombre de la URL corta
» sincebodystringtrueFecha inicial año-mes-dia
» untilbodystringtrueFecha hasta año-mes-dia
» categorybodystringfalseCategoría que desea información detallada {date,hour,country,device,operatingSystem} URLs Premium adicional {region,city,brand,model,browser,lang}

Example responses

200 Response

{
"urlShort":"string",
"urlLong":"string",
"clicksNumber":0,
"metrics":[
{
"date":{
"property":"string",
"clicks":0
},
"hour":{
"property":"string",
"clicks":0,
"date":"string"
},
"country":{
"property":"string",
"clicks":0
},
"region":{
"property":"string",
"clicks":0
},
"city":{
"property":"string",
"clicks":0,
"countryIsoCode":"string",
"region":"string",
"percent":0
},
"device":{
"property":"string",
"clicks":0
},
"brand":{
"property":"string",
"clicks":0,
"percent":0
},
"model":{
"property":"string",
"clicks":0,
"percent":0
},
"operatingSystem":{
"property":"string",
"clicks":0
},
"browser":{
"property":"string",
"clicks":0
},
"lang":{
"property":"string",
"clicks":0
}
}
]
}

Responses

StatusMeaningDescriptionSchema
200OKRespuesta exitosa de la operacionResponseStatistic
520UnknownParametros invalidosErrorResponse

Schemas

ResponseBalance

{
"status":0
}

Properties

NameTypeRequiredRestrictionsDescription
statusinteger(int64)falsenonenone

ErrorResponseBalance

{
"error":"string",
"msg":"string"
}

Properties

NameTypeRequiredRestrictionsDescription
errorstringfalsenonenone
msgstringfalsenonenone

ResponseURLShort

{
"urlShort":"string",
"urlLong":"string",
"msg":"string"
}

Properties

NameTypeRequiredRestrictionsDescription
urlShortstringfalsenonenone
urlLongstringfalsenonenone
msgstringfalsenonenone

ResponseStatistic

{
"urlShort":"string",
"urlLong":"string",
"clicksNumber":0,
"metrics":[
{
"date":{
"property":"string",
"clicks":0
},
"hour":{
"property":"string",
"clicks":0,
"date":"string"
},
"country":{
"property":"string",
"clicks":0
},
"region":{
"property":"string",
"clicks":0
},
"city":{
"property":"string",
"clicks":0,
"countryIsoCode":"string",
"region":"string",
"percent":0
},
"device":{
"property":"string",
"clicks":0
},
"brand":{
"property":"string",
"clicks":0,
"percent":0
},
"model":{
"property":"string",
"clicks":0,
"percent":0
},
"operatingSystem":{
"property":"string",
"clicks":0
},
"browser":{
"property":"string",
"clicks":0
},
"lang":{
"property":"string",
"clicks":0
}
}
]
}

Properties

NameTypeRequiredRestrictionsDescription
urlShortstringfalsenonenone
urlLongstringfalsenonenone
clicksNumberintegerfalsenonenone
metrics[object]falsenoneEstadísticas completas de una URL Premium
» dateobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
» hourobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
»» datestringfalsenonenone
» countryobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
» regionobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
» cityobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
»» countryIsoCodestringfalsenonenone
»» regionstringfalsenonenone
»» percentinteger(double)falsenonenone
» deviceobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
» brandobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
»» percentinteger(double)falsenonenone
» modelobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
»» percentinteger(double)falsenonenone
» operatingSystemobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
» browserobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone
» langobjectfalsenonenone
»» propertystringfalsenonenone
»» clicksintegerfalsenonenone

ErrorResponse

{
"error":"string",
"msg":"string"
}

Properties

NameTypeRequiredRestrictionsDescription
errorstringfalsenonenone
msgstringfalsenonenone