Integrieren Sie die PDF-Speicherung von nly.kr in Ihren Dienst.
Die API unterstützt nur doc_type=html oder text; je nach Typ ist html_content oder text_content erforderlich.
01
Endpunkt
POSThttps://nly.kr/api/pdf_save
Content-Type: application/x-www-form-urlencoded
02
Authentifizierung
Senden Sie den API-Schlüssel zur Authentifizierung auf eine der folgenden Arten.
{
"status": "error",
"message": "Die API erlaubt für doc_type nur html oder text."
}
400 — Ungültige Anfrage (fehlender oder ungültiger Parameter)
401 — Nicht autorisiert (fehlender oder ungültiger API-Schlüssel)
405 — Methode nicht erlaubt
500 — Serverfehler
Codebeispiele v1.0
# =========================
# 1) Save HTML (default: public)
# - For doc_type=html, use html_content
# - is_private default: 0 (public)
# =========================
curl -sS -X POST "https://nly.kr/api/pdf_save" \\
-d "api_key=your_API_KEY" \\
-d "doc_type=html" \\
-d "doc_title=API HTML Test" \\
-d "is_private=0" \\
-d "password=" \\
--data-urlencode 'html_content=<h1>Hello</h1><p>API save test</p>'
# =========================
# 2) Save TEXT (default: public)
# - For doc_type=text, use text_content
# =========================
curl -sS -X POST "https://nly.kr/api/pdf_save" \\
-d "api_key=your_API_KEY" \\
-d "doc_type=text" \\
-d "doc_title=API TEXT Test" \\
-d "is_private=0" \\
-d "password=" \\
--data-urlencode 'text_content=Hello.\nThis text will be saved as a PDF.'
# =========================
# 3) Private (password-protected) example
# - password is required when is_private=1
# =========================
curl -sS -X POST "https://nly.kr/api/pdf_save" \\
-d "api_key=your_API_KEY" \\
-d "doc_type=html" \\
-d "doc_title=Private document" \\
-d "is_private=1" \\
-d "password=1234" \\
--data-urlencode 'html_content=<h1>Private</h1><p>Private document</p>'
<?php
\$apiKey = 'your_API_KEY';
/**
* doc_type: html | text
* - html: html_content required
* - text: text_content required
*
* is_private: default 0 (public)
* - password is required when set to 1
*/
// 1) HTML example
\$payload = [
'api_key' => \$apiKey,
'doc_type' => 'html',
'doc_title' => 'API HTML Test',
'is_private' => '0', // public by default
'password' => '', // leave blank when public
'html_content' => '<h1>Hello</h1><p>API save test</p>',
];
\$ch = curl_init('https://nly.kr/api/pdf_save');
curl_setopt_array(\$ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(\$payload),
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded',
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
\$res = curl_exec(\$ch);
\$http = curl_getinfo(\$ch, CURLINFO_HTTP_CODE);
\$err = curl_error(\$ch);
curl_close(\$ch);
if (\$res === false) {
die("curl error: {\$err}\\n");
}
echo "HTTP: {\$http}\\n";
echo \$res;
/**
* doc_type: html | text
* - html: html_content required
* - text: text_content required
*
* is_private: default 0 (public)
* - password is required when set to 1
*/
const apiKey = "your_API_KEY";
// HTML example
const body = new URLSearchParams({
api_key: apiKey,
doc_type: "html",
doc_title: "API HTML Test",
is_private: "0",
password: "",
html_content: "<h1>Hello</h1><p>API save test</p>",
});
fetch("https://nly.kr/api/pdf_save", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
},
body,
})
.then(async (r) => {
const data = await r.json().catch(() => null);
if (!r.ok) throw { status: r.status, data };
return data;
})
.then(console.log)
.catch((e) => console.error("ERROR", e.status || "", e.data || e));
import axios from "axios";
/**
* doc_type: html | text
* - html: html_content required
* - text: text_content required
*
* is_private: default 0 (public)
* - password is required when set to 1
*/
const apiKey = "your_API_KEY";
(async () => {
try {
const params = new URLSearchParams();
params.append("api_key", apiKey);
params.append("doc_type", "html");
params.append("doc_title", "API HTML Test");
params.append("is_private", "0");
params.append("password", "");
params.append("html_content", "<h1>Hello</h1><p>API save test</p>");
const res = await axios.post("https://nly.kr/api/pdf_save", params, {
headers: {
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
timeout: 30000,
});
console.log(res.data);
} catch (error) {
const status = error.response?.status;
const data = error.response?.data;
console.error("ERROR", status || "", data || error.message);
}
})();
import requests
"""
doc_type: html | text
- html: html_content required
- text: text_content required
is_private: default 0 (public)
- password is required when set to 1
"""
api_key = "your_API_KEY"
payload = {
"api_key": api_key,
"doc_type": "html",
"doc_title": "API HTML Test",
"is_private": "0",
"password": "",
"html_content": "<h1>Hello</h1><p>API save test</p>",
}
res = requests.post(
"https://nly.kr/api/pdf_save",
headers={"Accept": "application/json"},
data=payload,
timeout=30,
)
print("HTTP:", res.status_code)
print(res.text)
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
)
func main() {
// doc_type: html | text
// - html: html_content required
// - text: text_content required
//
// is_private: default 0 (public)
// - password is required when set to 1
apiKey := "your_API_KEY"
form := url.Values{}
form.Set("api_key", apiKey)
form.Set("doc_type", "html")
form.Set("doc_title", "API HTML Test")
form.Set("is_private", "0")
form.Set("password", "")
form.Set("html_content", "<h1>Hello</h1><p>API save test</p>")
client := &http.Client{Timeout: 30 * time.Second}
req, _ := http.NewRequest("POST", "https://nly.kr/api/pdf_save", strings.NewReader(form.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Accept", "application/json")
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println("HTTP:", resp.StatusCode)
fmt.Println(string(b))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) throws Exception {
// doc_type: html | text
// - html: html_content required
// - text: text_content required
//
// is_private: default 0 (public)
// - password is required when set to 1
String apiKey = "your_API_KEY";
Map<String, String> params = new LinkedHashMap<>();
params.put("api_key", apiKey);
params.put("doc_type", "html");
params.put("doc_title", "API HTML Test");
params.put("is_private", "0");
params.put("password", "");
params.put("html_content", "<h1>Hello</h1><p>API save test</p>");
String form = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8)
+ "="
+ URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(5))
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://nly.kr/api/pdf_save"))
.timeout(Duration.ofSeconds(30))
.header("Content-Type", "application/x-www-form-urlencoded")
.header("Accept", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(form))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("HTTP: " + response.statusCode());
System.out.println(response.body());
}
}
import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) throws Exception {
// doc_type: html | text
// - html: html_content required
// - text: text_content required
//
// is_private: default 0 (public)
// - password is required when set to 1
String apiKey = "your_API_KEY";
URL u = new URL("https://nly.kr/api/pdf_save");
HttpURLConnection con = (HttpURLConnection) u.openConnection();
con.setRequestMethod("POST");
con.setConnectTimeout(5000);
con.setReadTimeout(30000);
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
con.setRequestProperty("Accept", "application/json");
StringBuilder body = new StringBuilder();
body.append("api_key=").append(URLEncoder.encode(apiKey, "UTF-8"));
body.append("&doc_type=").append(URLEncoder.encode("html", "UTF-8"));
body.append("&doc_title=").append(URLEncoder.encode("API HTML Test", "UTF-8"));
body.append("&is_private=").append(URLEncoder.encode("0", "UTF-8"));
body.append("&password=").append(URLEncoder.encode("", "UTF-8"));
body.append("&html_content=").append(URLEncoder.encode("<h1>Hello</h1><p>API save test</p>", "UTF-8"));
try (OutputStream os = con.getOutputStream()) {
os.write(body.toString().getBytes(StandardCharsets.UTF_8));
}
int code = con.getResponseCode();
InputStream is = (code >= 200 && code < 400) ? con.getInputStream() : con.getErrorStream();
StringBuilder sb = new StringBuilder();
try (BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
String line;
while ((line = br.readLine()) != null) sb.append(line);
}
System.out.println("HTTP: " + code);
System.out.println(sb.toString());
}
}
import okhttp3.*
import java.util.concurrent.TimeUnit
fun main() {
// doc_type: html | text
// - html: html_content required
// - text: text_content required
//
// is_private: default 0 (public)
// - password is required when set to 1
val apiKey = "your_API_KEY"
val client = OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build()
val body = FormBody.Builder()
.add("api_key", apiKey)
.add("doc_type", "html")
.add("doc_title", "API HTML Test")
.add("is_private", "0")
.add("password", "")
.add("html_content", "<h1>Hello</h1><p>API save test</p>")
.build()
val request = Request.Builder()
.url("https://nly.kr/api/pdf_save")
.addHeader("Accept", "application/json")
.post(body)
.build()
client.newCall(request).execute().use { res ->
println("HTTP: \${res.code}")
println(res.body?.string())
}
}
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main() {
// doc_type: html | text
// - html: html_content required
// - text: text_content required
//
// is_private: default 0 (public)
// - password is required when set to 1
var apiKey = "your_API_KEY";
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
client.DefaultRequestHeaders.Add("Accept", "application/json");
var content = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("api_key", apiKey),
new KeyValuePair<string, string>("doc_type", "html"),
new KeyValuePair<string, string>("doc_title", "API HTML Test"),
new KeyValuePair<string, string>("is_private", "0"),
new KeyValuePair<string, string>("password", ""),
new KeyValuePair<string, string>("html_content", "<h1>Hello</h1><p>API save test</p>"),
});
var res = await client.PostAsync("https://nly.kr/api/pdf_save", content);
var body = await res.Content.ReadAsStringAsync();
Console.WriteLine("HTTP: " + (int)res.StatusCode);
Console.WriteLine(body);
}
}
require "net/http"
require "uri"
# doc_type: html | text
# - html: html_content required
# - text: text_content required
#
# is_private: default 0 (public)
# - password is required when set to 1
api_key = "your_API_KEY"
uri = URI("https://nly.kr/api/pdf_save")
req = Net::HTTP::Post.new(uri)
req["Accept"] = "application/json"
req.set_form_data({
"api_key" => api_key,
"doc_type" => "html",
"doc_title" => "API HTML Test",
"is_private" => "0",
"password" => "",
"html_content" => "<h1>Hello</h1><p>API save test</p>",
})
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, open_timeout: 5, read_timeout: 30) do |http|
http.request(req)
end
puts "HTTP: #{res.code}"
puts res.body
use reqwest::Client;
use std::collections::HashMap;
use std::time::Duration;
#[tokio::main]
async fn main() {
// doc_type: html | text
// - html: html_content required
// - text: text_content required
//
// is_private: default 0 (public)
// - password is required when set to 1
let api_key = "your_API_KEY";
let mut form = HashMap::new();
form.insert("api_key", api_key);
form.insert("doc_type", "html");
form.insert("doc_title", "API HTML Test");
form.insert("is_private", "0");
form.insert("password", "");
form.insert("html_content", "<h1>Hello</h1><p>API save test</p>");
let client = Client::builder()
.timeout(Duration::from_secs(30))
.build()
.unwrap();
let res = client
.post("https://nly.kr/api/pdf_save")
.header("Accept", "application/json")
.form(&form)
.send()
.await
.unwrap();
let status = res.status();
let body = res.text().await.unwrap();
println!("HTTP: {}", status);
println!("{}", body);
}
Benötigen Sie Hilfe?
Wenn Sie bei der API-Integration Probleme haben, können Sie uns jederzeit kontaktieren.