API para desarrolladores de Vivoldi
Con la API REST de Vivoldi, puedes implementar funciones automatizadas y personalizadas en cualquier entorno — ya sea un sitio web, una aplicación móvil o un sistema interno.
Está diseñada para permitirte controlar las funciones clave de forma programática desde tu servidor o aplicación, sin necesidad de acceder directamente al panel de control.
La API se puede utilizar libremente desde diversos lenguajes y plataformas como JavaScript, Python, PHP, Java, Android e iOS.
Cada funcionalidad se ofrece de manera concisa e intuitiva, mejorando significativamente la eficiencia del desarrollo.
Para utilizar la API, necesitas una clave API para autenticación. Asegúrate de almacenarla de forma segura y de que no se exponga públicamente.
✨ Notas importantes:
- La clave API se puede cambiar una vez al mes como máximo.
- Los usuarios del plan gratuito también pueden utilizar la API sin restricciones.
- La frecuencia de solicitudes y la velocidad de respuesta pueden variar según el plan contratado.
- Si recibes un error HTTP 403, asegúrate de establecer un valor único para el encabezado User-Agent en tus solicitudes.
Vivoldi bloquea ciertos User-Agent que se asocian con bots o rastreadores maliciosos.
Se recomienda incluir el nombre de tu empresa o marca en inglés de forma clara en el valor del User-Agent. - Las llamadas a la API pueden fallar ocasionalmente debido a reinicios del servidor o mantenimiento del sistema.
Esto puede ocurrir durante actualizaciones de funciones, parches de seguridad o mantenimiento de infraestructura.
Por favor, asegúrate de incluir una lógica de reintento automático en todas tus solicitudes a la API.
Cómo llamar a la API
Host: https://vivoldi.com/api/{uri}
Authorization: APIKey {Your API Key}
Content-type: application/json
User-agent: {Your User-agent}
Accept-Language: en
{
"code": 0,
"message": "",
"result": Object
}
Campos | Descripción | Tipo |
---|---|---|
code | Código de respuesta. Un valor de 0 indica éxito; cualquier otro valor indica fallo.Este código es independiente del estado HTTP y se devuelve solo si el estado HTTP está en el rango 2xx o 3xx. | int |
message | Incluido solo si code no es 0. Proporciona un mensaje de error que explica el fallo.Puede estar vacío o no aparecer en caso de éxito. | string |
result | Los datos reales devueltos por la API. Según el tipo de API, el formato puede ser una cadena de texto o un objeto JSON . | object |
Examples:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script src="https://code.jquery.com/jquery-3.4.1.min.js" crossorigin="anonymous"></script>
</head>
<body>
<form id="exampleForm">
<button id="btnCreateLink" type="button">Create Link</button>
</form>
<script type="text/javascript">
$(function(){
$("#btnCreateLink").on('click', function(evt){
evt.preventDefault();
$.ajax({
type: 'POST',
url: 'https://vivoldi.com/api/link/v2/create',
data: JSON.stringify({'url':'https://google.com','domain':'https://vvd.bz'}),
headers: {'Authorization':'APIKey oc3w9m4ytso9mv5e8yse9XXXXXXXXXX'},
contentType: 'application/json; charset=utf-8',
dataType: 'json',
timeout: 5000
}).done(function(res){
if (res.code === 0) {
alert('short url: ' + res.result);
} else {
alert('code: ' + res.code + ', message: ' + res.message);
}
}).fail(function(xhr, textStatus, e){
alert('error: ' + e);
});
});
});
</script>
</body>
</html>
<?php
$url = "https://vivoldi.com/api/link/v2/create";
$params = array (
"url" => "https://www.facebook.com/vivoldi365",
"domain" => "https://vvd.bz",
);
$body = json_encode($params);
$headers = array(
"Authorization: APIKey oc3w9m4ytso9mv5e8yse9XXXXXXXXXX",
"Content-Type: application/json"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10000);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$result = curl_exec($ch);
if ($result === FALSE) {
echo "Error sending: " . curl_error($ch);
} else {
print_r($result);
}
curl_close($ch);
?>
package com.example;
import org.json.JSONObject;
import org.springframework.http.HttpStatus;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class CreateLink {
public static void main(String[] args) {
try (HttpClient client = HttpClient.newBuilder().build()) {
JSONObject params = new JSONObject();
params.put("url", "https://www.facebook.com/vivoldi365");
params.put("domain", "https://vvd.bz");
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://vivoldi.com/api/link/v2/create"))
.header("Content-Type", "application/json")
.header("Authorization", "APIKey oc3w9m4ytso9mv5e8yse9XXXXXXXXXX")
.POST(HttpRequest.BodyPublishers.ofString(params.toString()))
.build();
HttpResponse<String> response;
try {
response = client.send(request, HttpResponse.BodyHandlers.ofString());
} catch (Exception e) {
throw new RuntimeException(e);
}
if (response != null) {
if (response.statusCode() == HttpStatus.OK.value()) {
String jsonString = response.body();
if (jsonString != null && !jsonString.isEmpty()) {
JSONObject json = new JSONObject(jsonString);
if (json.getInt("code") == 0) {
System.out.println("Short URL: " + json.getString("result"));
} else {
System.out.println("Failed: " + String.format("[%d] %s", json.getInt("code"), json.getString("message")));
}
}
}
}
}
}
}