Topics

Tribe Support

Tribe Support's Topics

Akgora Flip

Akgora Flip

April 14 2020

Anahitha API documentation

Hi,

I would like to use API of Anahita can you provide a detailed document on this or walk me through how can we start using it for mobile app development. Do it require to stick to a specific framework, could help me out on this.

#Anahita #Documentation #Roadmap #Vision #Resources

Rastin Mehr
Rastin Mehr
April 14 2020 Permalink
Welcome to Anahita tribes Akgora, we don't have API documentation, because the codebase is changing a lot and keeping up with documentation is an added overhead. The good news, however, is that Anahita follows convention over configuration wherever possible, so you can generally construct the API endpoints. The best resources to learn and develop Anahita right now are:

1. reading the code in Anahita apps: https://github.com/anahitasocial/anahita/tree/master/packages

2. reading the code in Anahita React app: https://github.com/anahitasocial/anahita-react especially how it make REST API calls https://github.com/anahitasocial/anahita-react/tree/master/src/api

3. posting questions on this group which tribe members, as well as myself personally, will answer. Please make sure to use Gist https://gist.github.com/ to post your code snips here. Basically, once you make a gist, just copy-paste the URL here and Anahita renders the code snip.

4. Follow the project group to receive updates and read the blog posts, expect please don't post support related questions on that group: https://www.getanahita.com/groups/42242-anahita-project

5. paid consulting is available in our company. I personally have worked with teams and shown them the best practices and methods to build their projects using Anahita. https://www.rmdstudio.com/contact/

LAST IMPORTANT NOTE: don't invest much in Anahita's existing HTML rendering. Once our Anahita React app is ready, we will be removing all the code in the back-end that renders HTML and only keep JSON rendering. Basically Anahita will become an API-only backend service for browser, mobile, or desktop apps.



Akgora Flip liked this
Akgora Flip
Akgora Flip
April 15 2020 Permalink
I really appreciate your efforts to quickly respond to the topic to help me out. Well that was informative, but how to generate REST API Endpoints using existing Anahitha code. As i can see react app with API for data operations. What is the backend framework used on which Anahitha is build on. How to utilize existing code to generate endpoint REST API's. Do you have any API base url for getting the data. Could you give me a detailed information on how to build API with existing Anahitha code. Thanks in Advance.
Rastin Mehr liked this
Rastin Mehr
Rastin Mehr
April 15 2020 Permalink
When you are building apps, you are building RESTful APIs at the same time. A lot of it is already taken care of by the Anahita framework. In rare cases, you need to write custom outputs for a particular call.
Akgora Flip liked this
Rastin Mehr
Rastin Mehr
April 15 2020 Permalink
For example, take a look at the topics app. It doesn't have any specific code for endpoints. All you have to do is to either pass format=json in your URL or just add .json in the end. For example https://www.getanahita.com/topics.json

or this topic that you have started https://www.getanahita.com/topics/167916-anahitha-api-documentation.json
Akgora Flip liked this
Akgora Flip
Akgora Flip
April 16 2020 Permalink
Rastin thank you for the quick response again. The information provided is fetching me data from Anahitha, but i have few queries.
How to authenticate the API for user. And how users data is separated, how do i get a particular user post. Could you please give an overview of how play around anahitha using REST API.
Rastin Mehr liked this
Rastin Mehr
Rastin Mehr
April 16 2020 Permalink
Here is an example of creating a session: https://github.com/anahitasocial/anahita-react/blob/master/src/api/session.js

Here are my photos: https://www.getanahita.com/photos.json?oid=5

oid is owner id

This is the higher order module that creates API calls in our react app: https://github.com/anahitasocial/anahita-react/blob/master/src/api/create.js

namespace can be: people, photos, topics, todos, etc. basically every component.
Akgora Flip liked this
Akgora Flip
Akgora Flip
April 17 2020 Permalink
Thanks again for your quick response Rastin. That was really helpful, another query regarding API example in this link https://www.getanahita.com/people.json the data is fetched when run in a browser. With reference to anahitha react app in the link https://github.com/anahitasocial/anahita-react/blob/master/src/api/signup.js you can see add method where data posted to using '/people/person.json' with an action signup in that method. Now i want to know whether people.json and people/person.json the same or how is it related what is the middleware(like node,php etc) used to link the data to API could you briefly explain what methodology is used, this so that it will help us in writing customized API if required.
Also could you provide the react version app(link for cloning) of anahitha for installation purpose.
Thanks in advance.
Rastin Mehr
Rastin Mehr
April 17 2020 Permalink
Let me get back to you on this after the weekend. I'll be working on the people component both in the PHP and React App, there may be changes in the code.
Akgora Flip liked this
Rastin Mehr
Rastin Mehr
April 17 2020 Permalink
To play with the React App, you need to first install Anahita and set it up on the localhost. Then you need to configure the CORS to receive requests from localhost:3000 then install the react app. Right now, this is the only way, until we built a Docker image for Anahita which will streamline the process of setting up an instance.
Akgora Flip liked this
Akgora Flip
Akgora Flip
April 18 2020 Permalink
Thank you Rastin, I really appreciate the efforts in responding to my queries. Could you confirm which link is the react version of Anahita below.
1) https://github.com/anahitasocial/anahita
2) https://github.com/anahitasocial/anahita-react

Also on which OS is it compatible to install i.e - windows/linux.
Could you provide the steps for installation.
Rastin Mehr
Rastin Mehr
April 18 2020 Permalink
Ideally Linux or macOS, but if you can install a Wordpress on your local machine, you should be able to install Anahita as well. Windows users had to take some extra steps to be able to create symlinks on their machines but looks like symlinks are supported natively on Windows 10. Try and let me know.
Akgora Flip liked this
Rastin Mehr
Rastin Mehr
April 18 2020 Permalink
To set up the react app, you just need the standard commands for a Create React App:

$ yarn init
$ yarn start
Rastin Mehr
Rastin Mehr
April 20 2020 Permalink
Check the file https://github.com/anahitasocial/anahita-react/blob/master/src/api/signup.js and it now has the correct signup path.

Right now, Anahita sends out an activation link that users must click on to log on for the first time. The activation link doesn't yet work with the Anahita React app. We are even considering removing the activation link concept and autologin the user. To avoid bots, we can rely on #GoogleRecaptcha, which is more sophisticated than anything we want to focus on building.
Akgora Flip
Akgora Flip
April 21 2020 Permalink
Hi Rastin, how do i setup react version of anahitha locally as i have a windows 10 OS. Could you walk me through in detail step by step, so that i can carry out creating symlinks which you told me to let you know.
Rastin Mehr
Rastin Mehr
April 22 2020 Permalink
A lot of people use MAMP https://www.mamp.info/en/windows/ to set up their local LAMP or LEMP environments. I am currently using MAMP for OSX myself. My goal is to offer Anahita on Docker and Kubernetes so people can setup development, staging, and production environments on AWS or other cloud providers.
Akgora Flip liked this
Akgora Flip
Akgora Flip
April 22 2020 Permalink
Thanks for the update Rastin. Can I download MAMP for windows10 and install react version of anahitha for time being. Is there any particular methodology for that or how is it could you guide me through how to install it as i know how to install wordpress using xampp.
Rastin Mehr
Rastin Mehr
April 22 2020 Permalink
For the React environment to work on your machine, you just need to install NodeJS, yarn, and npm. They are platform agnostic. This is the generic Create React App https://github.com/facebook/create-react-app

Anahita React setup is basically the same. You just need to setup Anahita to become the back-end API on the localhost and react app on localhost:3000 as the client-side app.
Akgora Flip liked this
Akgora Flip
Akgora Flip
April 22 2020 Permalink
Hi Rastin i tried to install the react version but few errors have been encountered as below.
Tried many ways of fixing react errors but could do it only to some extent.
./src/containers/stories/comments/Browse.js
Module not found: Can't resolve '../../../formfields/field' in 'D:testanahita-reactsrccontainersstoriescomments'.

Could you provide assistance on setting up the react version of anahita on local( backend and frontend together OR separately whichever possible easily.
Akgora Flip liked this
Akgora Flip
Akgora Flip
April 24 2020 Permalink
Hi Rastin,
I have installed the react app on my local machine windows 10.
1. I have cloned anahita-react repo and did a yarn init and yarn install.
2. when i run the npm start i get the following build error
Module not found: Can't resolve '../../../formfields/field' in 'C:MAMPhtdocsReactsrccontainersstoriescomments'

I further investigated and see that
in containers/stories/coments/browse.js
the following two import files are missing in the
import field from '../../../formfields/field';
can you please add the formfields/field.js
Thanks in Advance
Rastin Mehr liked this

Powered by Anahita