Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Deaktivieren der JSON REST API in WordPress

Wir haben vor kurzem eine Frage von einem Besucher erhalten, die wir hier ziemlich oft hören: „Wie deaktiviere ich das REST-API auf meiner WordPress Website?“ Und ganz ehrlich, das ist ein gültiges Anliegen.

Als WordPress in der Version 4.4 mit der JSON REST-API veröffentlicht wurde, eröffnete dies den Entwicklern eine Welt voller Möglichkeiten.

Für viele Website-Besitzer, die diese erweiterten Funktionen nicht benötigen, kann die API jedoch wie eine unnötige Ergänzung erscheinen, die ihre Website potenziell für Sicherheitsrisiken öffnet.

In diesem Artikel zeigen wir Ihnen, wie Sie das JSON REST-API in WordPress ganz einfach deaktivieren können.

Disable JSON REST API in WordPress

Warum JSON REST API in WordPress deaktivieren?

Es lässt sich nicht leugnen, dass die API viele Vorteile für WordPress-Entwickler hat. Die API macht es super einfach, Daten über GET-Anfragen abzurufen, was für die Erstellung von Anwendungen mit WordPress nützlich ist.

Dies könnte Ihre Website jedoch potenziell für eine neue Front von DDoS-Angriffen öffnen. Es kann auch ressourcenintensiv sein und Ihre WordPress-Website verlangsamen.

Die Deaktivierung von JSON REST API ist vergleichbar mit der Deaktivierung von XML-RPC, die viele Website-Administratoren auf ihren WordPress-Sites deaktivieren, um auf der sicheren Seite zu sein.

Wir zeigen Ihnen zwei Methoden zum einfachen Deaktivieren von JSON REST-API in WordPress. Verwenden Sie einfach die Links unten, um zu der gewünschten Methode zu springen:

Methode 1. Deaktivieren der JSON REST API in WordPress mit Code (empfohlen)

Wenn es darum geht, WordPress-Funktionen zu ändern, ist die Verwendung von Code-Snippets oft der beste Ansatz. Aber die direkte Bearbeitung der Datei functions.php Ihres Themes kann riskant sein und Ihre Website zerstören, wenn sie nicht korrekt ausgeführt wird.

Deshalb empfehlen wir die Verwendung des WPCode Plugins, um JSON REST-API in WordPress zu deaktivieren.

Diese Methode macht es sicher und einfach, individuellen Code in WordPress hinzuzufügen, ohne die functions.php-Datei Ihres Themes zu bearbeiten. Auf diese Weise besteht kein Risiko, dass Sie einen Fehler machen und Ihre Website beschädigen.

WPCode

Außerdem verfügt WPCode über eine integrierte Code-Bibliothek mit geprüften Code-Schnipseln für beliebte Funktionen wie REST-API deaktivieren, XML-RPC deaktivieren und vieles mehr. So müssen Sie nicht eine ganze Reihe von Plugins für den einmaligen Gebrauch installieren.

Um loszulegen, müssen Sie das kostenlose WPCode Plugin installieren und aktivieren. Eine schrittweise Anleitung finden Sie in unserem Leitfaden zur Installation eines WordPress Plugins.

Hinweis: Die kostenlose Version von WPCode bietet alles, was Sie brauchen, um benutzerdefinierten Code in WordPress hinzuzufügen. Wenn Sie jedoch erweiterte Funktionen wie eine private Cloud-Snippets-Bibliothek, seiten- und gerätespezifische Snippets, Code-Revisionen und mehr wünschen, können Sie auf WPCode Pro upgraden.

Sobald das Plugin aktiviert ist, gehen Sie in Ihrem WordPress-Dashboard zu Code Snippets “ Library.

Suchen Sie dann nach dem Snippet „Disable WordPress REST API“ und klicken Sie auf die Schaltfläche „Use snippet“.

Select the Disable WordPress REST API in WPCode

Das Plugin fügt dann automatisch den Code ein und wählt die richtige Einfügemethode.

WPCode automatically adds the Disable JSON REST API snippet

Dazu müssen Sie lediglich den Schalter von „Inaktiv“ auf „Aktiv“ umlegen.

Klicken Sie dann auf die Schaltfläche „Aktualisieren“.

Switch the code snippet to Active and click Update in WPCode

Das war’s. Jetzt ist die JSON REST API auf Ihrer WordPress-Website deaktiviert.

Methode 2. Deaktivieren der JSON REST API in WordPress mit einem Plugin

Sie können die JSON REST-API auch ganz einfach mit Hilfe eines speziellen Plugins deaktivieren.

Als Erstes müssen Sie das Plugin Disable REST-API installieren und aktivieren. Weitere Einzelheiten finden Sie in unserer Schritt-für-Schritt-Anleitung für die Installation eines WordPress Plugins.

Das Plugin ist sofort einsatzbereit und es gibt keine Einstellungen, die Sie vornehmen müssen.

Nach der Aktivierung gibt das Plugin bei allen API-Anfragen von Quellen, die nicht bei Ihrer Website angemeldet sind, zwangsweise einen Authentifizierungsfehler zurück.

Dadurch wird verhindert, dass nicht autorisierte Anfragen die REST-API nutzen, um Informationen von Ihrer Website abzurufen.

Sie können dies testen, indem Sie die Seite http://example.com/wp-json besuchen. Stellen Sie sicher, dass Sie sich zuerst im WordPress-Administrationsbereich abmelden, oder schalten Sie Ihren Browser in den Inkognito-Modus.

Vergessen Sie nicht, example.com durch Ihren eigenen Domänennamen zu ersetzen. Sie sehen diese Meldung, die anzeigt, dass REST-API-Anforderungen blockiert sind.

REST API Disabled

Das war’s. Sie haben erfolgreich nicht autorisierte REST-API-Anfragen auf Ihrer WordPress-Website deaktiviert.

Wir hoffen, dass dieser Artikel Ihnen geholfen hat zu lernen, wie man JSON API in WordPress deaktiviert. Sicherheitsbewusste Benutzer sollten sich auch diese Tipps zum Schutz des WordPress-Administrationsbereichs ansehen oder sich unsere Auswahl der besten WordPress-Backup Plugins ansehen.

Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

36 KommentareLeave a Reply

  1. RJW

    I’d try the disable plugin in Dev environment before production, I found installing it broke some features

    • WPBeginner Support

      If you have many different plugins and tools and have a testing environment then it would definitely be good to test new plugins and how they interact with your site.

      Admin

  2. Ricky

    Similar to an above commenter, I’ve noticed the „wp-json“ request when using Pingdom and other testing sites. Unfortunately, mine takes over 10 seconds (Yes really!!) to load it. This pushes my overall website load time and I can’t figure out how to fix this. The plugin doesn’t change it at all. Any suggestions?

  3. Janice

    How do I know if I actually have JSON API on my website?
    This article about removing it is good – if I need it – but I have often been alarmed by certain warnings only to find that they’ve not even applicable to me.

  4. Logan Cale

    I hate adding yet another plugin to do a simple tasks, and I found that we can disable this functionality by adding the following code snippet to the functions.php file.

    add_filter(‚rest_enabled‘, ‚_return_false‘);
    add_filter(‚rest_jsonp_enabled‘, ‚_return_false‘);

    • Margarit Koka

      Thank you bro, your answer is what I was looking when visiting this page.

    • Bobby C.

      Thank you! Straight to the point.

    • Hari

      I was looking for this code, it worked, thanks, I don’t prefer adding plugins.

  5. Michael

    Thanks for your help. There is no ‚add new‘ option in my plugins.

  6. Lynne

    Thank you! Spot on :) worked for me

  7. J.L.

    Is this just for self hosted blogs or including free blog sites? Per mostly all plug ins…etc are done for you when you’re not self hosted

    PS I’m not subscribing…just want a response

  8. Elaine

    How can I check if my site has Rest API. I turned off a lot of extras when I first set it up but now don’t know where to look to see if it’s there. Not keen to download a plugin unnecessarily.

    • WPBeginner Support

      Hey Elaine,

      You can check if rest is api is enabled on your site by visiting the url like this example.com/wp-json. Make sure you are signed out of WordPress before doing that. If you see lots of information in plain text, then this means REST API is enabled on your site. Follow the above instructions to turn it off

      Admin

  9. Saransh Jain

    What about the option to disable json rest api in Jetpack plugin?

  10. Ken Dowling

    Is disabling REST API suitable for e-commerce sites such as WooCommerce? My understanding is that WooCommerce uses REST-API quite a bit.

    Further, my buyers do not have to login to buy, so what happens to the transaction when a REST API call is rejected?

    Regards, Ken

  11. D. Joe Chaffin

    Plug-in makes no difference for me in WP 4.7.2. With the plugin activated or disabled, the example.com/wp-json (with my domain replacing „example“) pages gives a massive list of settings for my site.

    • D. Joe Chaffin

      Hmmmm. Now that I look at it, I only see the list in Safari, while Chrome and Firefox for Mac show the expected message specified in this post.

    • WPBeginner Support

      Hi,

      Make sure you are logged out of WordPress admin area or use incognito mode before testing the example.com/wp-json page. The plugin disables access to the page only for unauthorized users. As an administrator you will still be able to see it.

      Admin

      • D. Joe Chaffin

        Embarrassed… You are right, of course.

  12. Audra Carpenter

    Hey Guys,

    First off thanks so much for what you do! I’ve learned so much about WordPress from you and sent a ton of folks your way!!

    Ok, I installed the plugin, but I am not seeing what you suggest above? I have a full screen of information…?

    Thoughts?

    Thanks!

    • WPBeginner Support

      Hi Audra,

      Please logout or use incognito window to test. The plugin only disables access for non-logged in users.

      Admin

  13. Treasure

    I followed these steps, but when I went to check it with the example etc., I got 2 pages of code, not the response showed above. Hmmm, don’t know what to do.

    • Treasure

      Alright, I did it again and got the right message. Thanks!

  14. Doug Nix

    When I ran the test I think it failed, as I got a boatload of data on screen. Any idea what might have not worked? I installed the plugin as described…

    • Doug Nix

      Works perfectly when I check using an incognito window. Thanks for the explanation regarding authorised vs unauthorised or anonymous users.

  15. Laura Zielke

    Worked perfectly. Thank you!

  16. Karl

    Thanks for the tip as well as for the hook to disable XMLRPC.
    Is there a chance for a filter hook for the REST API as well?

  17. Andrew

    When I check the speed of my site using pingdom.com, the first html entry that tried to load shows the link as mydomain.com/wp-json and it has over 2 seconds of „wait“ time. Is this the same as what this article is talking about? I’m hesitant to simply disable it since I would assume it will be used in the future. Any idea why it would add a 2+ second delay to loading anything on the page?

  18. Stephen Cronin

    Hmm, the REST API is going to become the standard way for plugins and themes to make Ajax calls back to the server from the front end, replacing admin-ajax, so I wouldn’t be disabling it… Hopefully they will fail gracefully, but you will almost end up missing some functionality.

    Also, if you really want to protect against DDoS attacks, you better disable html as well! ;)

    • reza

      ver 50,000 WordPress websites have been hacked due to a major security vulnerability that was discovered in the WordPress REST API.

      • Jim S Smith

        OUCH!

        That’s disturbing to know. I have noticed a LOT of access attempts in my site’s logs.

        What’s more,

        I think the folks at WordPress could have done a little better in letting the users decide how much, if at all, they want the REST API exposed.

        Again,

        More of this, „The developers know MORE about the user’s needs than the user does!“ – I also was not too happy about being forced to support EMOJI and remote-loaded fonts from fonts.google.com, even though my sites do not use them!

        The REST API may be a boon for (some) actual web-application developers, but what about the rest of us who will not very likely use this? ? ?

  19. Kasey

    How likely is it that a plugin will be using this functionality. Just for example would contact forms be utilizing this? Not keen on turning it off in case it breaks anything.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.