Tutorial

The MUSIC Web API is implemented as a set of functions that can be called using XML SOAP protocols.

It can be invoked from a variety of platforms and scripting languages such .NET, Excel, Visual FoxPro and jQuery. Implementation typically involves adding a reference to the WSDL file and your programming environment will take care of the details.

In this tutorial for the MUSIC Web API, we will create a simple Visual Basic WinForms application using Visual Studio 2013. The demo application will show information pulled from the MUSIC database for a given barcode.

1. In Visual Studio, create a new "Windows Forms Application".

2. Select "Add Reference" from the Project menu.

3. In the "Add Web Reference" dialog, enter the WSDL URL (http://musicwebapi.coinnexus.com/services.asmx) and click the Go button to the right of the URL text field. The list of services from the MUSIC server will load. Change the "Web reference name" field to "musicwebapi".

3. Use the form designer to create a form with a single line textbox, a command button and a multi-line textbox. It should look like the image below.

Use the following names for each control:

top textbox = txtBarscan
commandbutton = cmdFetch
multi-line textbox = txtCoinInfo

4. Double click the "cmdFetch" button and past the following code into the cmdFetch.Click event. You will want to use your own API login and password on the 'GetCoinAttributes' line.

Private Sub cmdFetch_Click(sender As Object, e As EventArgs) Handles cmdFetch.Click
    Dim sBarcode As String = txtBarscan.Text
    Dim sOutput As String = ""

    Dim oMusicAPI As musicwebapi.services = Nothing
    Dim oCoinInfo As musicwebapi.cCoinAttributes = Nothing

    If sBarcode.Length = 0 Then Return

    'instantiate MUSIC object
    oMusicAPI = New musicwebapi.services

    'execute the call
    oCoinInfo = oMusicAPI.GetCoinAttributes(sBarcode, True, "01", "yourlogin", "password")

    'output some properties
    sOutput &= "Barscan:" & oCoinInfo.Barscan & vbCrLf
    sOutput &= "Description:" & oCoinInfo.Invoice & vbCrLf
    sOutput &= "Denomination:" & oCoinInfo.Denom & vbCrLf
    sOutput &= "Year & Mint Mark:" & oCoinInfo.YearMM & vbCrLf
    sOutput &= "Grade:" & oCoinInfo.Grade & IIf(oCoinInfo.Plus, "+", "") & vbCrLf

    Me.txtCoinInfo.Text = sOutput

    oMusicAPI = Nothing
    oCoinInfo = Nothing
End Sub

5. Save the project and press F5 to run it. Enter a valid coin barscan or PCGS number and click the "Get Coin Info" button. You should see output that looks like the screen below.