6

I am developing an android app. I dont know anything about wordpress database or how to get data from the website. I googled for how to get data from the wordpress database I have got to know I could get json response from JSON API plugin of the wordpress. but It's hard for me to understand.

I am using food bakery theme for wordpress.

I just want to know how do I get required json response from this website. And where the data of products in that website is located in database.

for example : product,categories etc. etc

My expected response is something like this

{"Category":[{"ProductSubGroupCategoryCode":"PSG03","ProductGroupCategoryCode":"PG01","Description":"WRAPS" ,"CHello SirreatedBy":"101","CreatedDate":"\/Date(1486116932060)\/","ModifiedBy":null,"ModifiedDate":null}]}, {"SubCategory":[{"ProductID":"01","Description":"VEG BURGER","ReferanceID":"VEG BURGER","UOM":"EA","AlterUOM":"EA", "ProductGroupCategoryCode":"PG01","ProductSubGroupCategoryCode":"PSG01","TaxCategoryCode":"","TaxCode":"VAT5","BuyPrice":100, "AttributeCode":"PA01","BasicPrice":190.48,"TaxRate":5.00,"SalesPrice":200.00,"ProductImage":null,"CurrentStock":10, "PlantCode":"PC01","StoreLocationCode":"S01","DisplayOnPOS":true,"POSDisplayOrder":0,"CreatedBy":"101", "CreatedDate":"\/Date(1486446663333)\/","ModifiedBy":"101","ModifiedDate":"\/Date(1486447253063)\/"} 

Edit: I tried with WP REST API i have come upto, when i use this link it gives me response with id 1 http://localhost/mysite/wp-json/wp/v2/posts/1. when when I have tried with other post IDs it gives me blank response.

FYI I got post ID for that certain post from wordpress_posts table of wordpress database

3 Answers 3

4
if you want to get post: 

https://example.com/wp-json/wp/v2/posts

if you want to get a particular post 

https://example.com/wp-json/wp/v2/posts/1852

 whereas 1852 is the id of the post 
Sign up to request clarification or add additional context in comments.

1 Comment

Not sure why the op did not set this answer as correct. Thank you, this helped me a lot!
1

For getting JSON response from word press site you need to install certain open source plugin on word press site here is an WP API link Click here As per documentation You can also create custom API

6 Comments

hi Siddharth Thakyou for your response, I check this API. But it sends response of all the products on that page. What if i want to load only certain products
Please read that documentation carefully. There is an option to get single post or page
I tried it now problem is I found one of my post item in the WordPress database table 'wordpress_posts` with ID = 1342 How can i access this? I have tried it with http://localhost/mysite/wp-json/wp/v2/posts/4223
It gives this response {"code":"rest_post_invalid_id","message":"Invalid post ID.","data":{"status":404}}
try to get post id from wordpress dashboard. There is also an option to get a single post by a slug
|
0

You can access your posts json on wordpress with

http://oursite.com/wp-json/wp/v2/posts

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.