The Developer API for version 7 has been released!


#1

Just a quick note to announce the new developer API for version 7. The new API is more modern than the V5 API and runs on a different stack. I think you’ll find it much easier to use. Unfortunately, it’s not compatible with the old version, but it does have more features.

Docs: https://www.surrealcms.com/docs/api.html

It’s currently in beta, so give it a try and let me know what you think!


#2

Was just wondering what other developers have been doing with the v5 API. Any projects available that we can see to get some inspiration of what we can achieve with the API?

Also: Just curious…do both v5 and v7 use MySQL for a database? Any link for Surreal tech stack for both v5 and v7?


#3

Both use MySQL. V5 is a PHP based app whereas version 7 runs on Node.


#4

Good work Cory!

It looks like a lot of work has been put into the API. How long have you been working on it?

I’ve done some testing for creating a user with the API and found some issues.

First of all, if you don’t send the password or message object, the server returns a 500 internal server error however if an empty message object is sent, the server returns 400 bad request with an error message. Maybe provide an error message and 400 bad request when no password or message object is sent.

Surreal CMS will send the welcome email with Surreal CMS branding if the user is created with https://edit.surrealcms.com/api/. I found that if I use my own clientcms.com subdomain for the API domain, the email is sent with my branding. This should be fixed so the correct branding is sent regardless of what domain is used for the API. Maybe the API could have an option to specify what branding is used in case someone wants to send the welcome email with Surreal CMS branding.

It would be nice to be able to change the welcome email button link. This would be useful if someone wanted to add their own link tracking or if they have a custom domain workaround. The only issue is that it would probably require two API requests as the welcomeToken is generated after the user is created.

Thank you Cory for releasing the API. I’m looking forward to Webhooks.


#5

First of all, if you don’t send the password or message object, the server returns a 500 internal server error however if an empty message object is sent, the server returns 400 bad request with an error message. Maybe provide an error message and 400 bad request when no password or message object is sent.

Thanks for the heads up. I’ll make sure there’s a more appropriate error message here.

Surreal CMS will send the welcome email with Surreal CMS branding if the user is created with https://edit.surrealcms.com/api/. I found that if I use my own clientcms.com subdomain for the API domain, the email is sent with my branding. This should be fixed so the correct branding is sent regardless of what domain is used for the API.

Good catch. API endpoints can also be access from custom domains, but this isn’t documented so that’s a quick workaround.

Currently, the app looks at the hostname to determine white-label options. The reason for this is the login page. If you’re not authenticated, what logo should be displayed? So it checks the domain.

What it should be doing is checking the authenticated user’s account first, and if they’re not authenticated fall back to a hostname check. This would cover users logged in at edit.surrealcms.com as well as API requests, regardless of the endpoint.

I’ll get this sorted soon.


#6

Update: this has been improved. If you’re logged in, you will always see the correct branding no matter what domain you’re on. The only time you won’t see it is if you’re on the login page at edit.surrealcms.com. (Of course, the correct branding will still show on your custom domain’s login page.)


#7

I don’t know about others, but I’ve found most use for the API as tool for a) making big batch changes to users, sites, etc.; and b) pulling out stats.


#8

Why didn’t you pick Mongo with Node since it’s kinda believed to be a sexy pair?


#9

Sexy doesn’t mean it’s the best solution. MySQL may not be sexy, but it’s fast and stable.