This information is aimed to developers only. If you're not a developer, you probably don't need to know about all this.

To get an API key, you should have access to a Megaventory account. If you don't have a Megaventory account, you can sign-up for free at: https://megaventory.com.

Once you sign-in to your Megaventory account, you may click the Profile Icon to access your profile information:

Then,

click the key icon to generate an API key and hit Update at the bottom:

Then, head over to https://api.megaventory.com

Example: getting all products

If you click on Product / ProductGet function, you'll see that you need to do a POST request to: https://api.megaventory.com/v2017a/Product/ProductGet with the payload (example):

{
"APIKEY": "YOURAPIKEYHERE"
}

to retrieve all your products.

You can also do a GET request for the same at the following URL: https://api.megaventory.com/v2017a/json/reply/ProductGet?APIKEY=YOURAPIKEYHERE

Example: inserting a client

A POST request to https://api.megaventory.com/v2017a/SupplierClient/SupplierClientUpdate with the following payload (example):

{
"APIKEY": "YOURAPIKEYHERE",
"mvSupplierClient": {
"SupplierClientID": 0,
"SupplierClientType": "Client",
"SupplierClientName": "My dummy client"
},
"mvRecordAction": "Insert"
}

will insert a new client with name "My dummy client"

Example: getting products with available quantity

To get the products with available quantity you can do a GET request at:

https://api.megaventory.com/v2017a/json/reply/InventoryLocationStockGet?APIKEY=YOURAPIKEYHERE&ShowOnlyProductsWithPositiveQty=1

or a POST request at: https://api.megaventory.com/v2017a/InventoryLocationStock/InventoryLocationStockGet with the appropriate body payload.

By doing so, you will get a response with all available products. Also, if you notice, there is a "query" parameter. This simulates more or less the behavior of an SQL query. For example (GET):

https://api.megaventory.com/v2017a/json/reply/InventoryLocationStockGet?APIKEY=YOURAPIKEYHERE&ShowOnlyProductsWithPositiveQty=1&query=mv.ProductSKU like '%000%'

will fetch products with positive quantity that include the '000' anywhere in the ProductSKU field. The thing to note is the mv. prefix that needs to be added before the usual fields that you'll find in the syntax of each API call.

Example: get suppliers or clients

For the SupplierClientGet:

https://api.megaventory.com/v2017a/json/reply/SupplierClientGet?APIKEY=YOURAPIKEYHERE&query=mv.SupplierClientName like '%mag%'

will bring all suppliers/clients that include 'mag' in their name. You can also use an AND/OR:

https://api.megaventory.com/v2017a/json/reply/SupplierClientGet?APIKEY=YOURAPIKEYHERE&query=mv.SupplierClientName like '%mag%' AND mv.SupplierClientType = 2

(mv.SupplierClientType = 2 is for strictly clients, mv.SupplierClientType = 1 is for strictly suppliers, mv.SupplierClientType = 0 is for entities that are both suppliers and clients).

A general note

Most API functions have an Update call (such as SupplierClientUpdate) with an mvRecordAction parameter. This can either be mvRecordAction=insert (create/insert) or mvRecordAction=update.

The metadata definition (JSON) of the SalesOrderGet/SalesOrderUpdate is here:

https://api.megaventory.com/v2017a/json/metadata?op=SalesOrderGet
https://api.megaventory.com/v2017a/json/metadata?op=SalesOrderUpdate

To get the SalesOrderClientID one should first call the SupplierClientGet (with the name of the supplier/Client) and extract the id. Same with the SalesOrderInventoryLocationID. Alternatively, one can store ids locally upon an initial sync.

Did this answer your question?