As software developers, we know how frustrating it can be to code a form backend to collect a few simple fields. This API makes it extremely easy to create a new form endpoint. It is an ideal solution for designers and developers, and you can create and use your form endpoint within seconds. All information submitted to this endpoint is automatically collected and stored for you. Moreover, with the browser, operating system, location and all other details of the person submitting the form.
We do not use any CSS libraries, no iframes and complex structures. Moreover, we generate single-use CSRF (cross site request forgery) tokens completely automatically and ensure the security of your forms. Thus, you protect yourself greatly from spambots.
How to use it
Start by creating a new form and giving it a name. Like:
curl --request POST \
--url 'https://api.apilayer.com/form' \
--header 'apikey: YOUR API KEY' \
--data-raw 'My cool form'
It will generate a form and return it's unique id and the URL for submission.
{
"id": "d2f1d1a6-dd80-11ea-9926-0242c0a83002",
"name": "My cool form",
"form_url": "https://form.codes/f/d2f1d1a6-dd80-11ea-9926-0242c0a83002"
}
Notice the form url above and use it anywhere as the action value of any HTML form on your code. Like:
<form action="https://form.codes/f/d2f1d1a6-dd80-11ea-9926-0242c0a83002" method="POST">
<input type="text" name="firstName" id="firstName">
<input type="email" name="emailAddress">
<textarea name="answer"></textarea>
</form>
<script type='text/javascript'>
(function() {
var wa = document.createElement('script'); wa.type = 'text/javascript'; wa.async = true;
wa.src = 'https://form.codes/csrf/d2f1d1a6-dd80-11ea-9926-0242c0a83002.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wa, s);
})();
</script>
Notice the script just below the HTML form. It is there to generate a unique CSRF token for your form and protect you from spammers. Do not forget it.
That's it. You are ready to go and collect any information submitted to this form and get all its details with a powerful API. Check the documentation tab for more details and also check form.codes web page for more details