Package: mirthpy
mirthpyPython api wrapper for Mirth ConnectNOTE:This api wrapper is not totally complete with all of Mirth's REST api calls. If you have a request for a specific api call, please make an issue on GitHub.Table of ContentsInstallationSetupUsageSupported Mirth API CallsInstallationUse the package managerpipto install mirthpy.pipinstallmirthpySetupConfig file must match the following:{"instanceName":"{instance IP or DNS Name}","credentials":{"username":"{username}","password":"{password}"}}alternatively you can provide the mirth instance (ip or domain name) and user/pass comboservice=MirthService(username="{username}",password="{password}",instance="{mirthInstance}")Usageimportjsonimportmirthpyimporturllib3urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)#to supress ssl warningconfig=json.load(open('config.json'))service=MirthService(config)service.open()# to login and initialize any service variables# Get channel namesnamesAndIds=service.getChannelIdsAndNames()forniinnamesAndIds.entry:print(f"{ni.string[1]}-{ni.string[0]}")# channelName - channelId# Get Id by nameid=service.getChannelIdByName('Test Channel')channel=service.getChannel(id)print(channel.name)print(channel.description)print(channel.sourceConnector.transformer)iftype(channel.sourceConnector.properties)==JavaScriptReceiverProperties:# do stuff we'd know only a javascript reader would havescript=channel.sourceConnector.properties.script# Get multiple channelschannelIds=["44dacc20-718a-490c-bfcf-82355ed9209d","3bb08639-7725-4b1b-a2ac-13687101fe9b"]c=service.getChannels(channelIds)forchannelinc.channels:print(channel.name)# Get all channelschannels=service.getChannels()forchannelinchannels.channels:print(f"{channel.name}-{channel.description}")# get all enabled channelsenabledChannels=[channelforchannelinchannels.channelsifchannel.exportData.metadata.enabled=='true']# get only javascript readersjReaders=[channelforchannelinenabledChannelsiftype(channel.sourceConnector.properties)==JavaScriptReceiverProperties]# get certain code templatescodeTemplates=service.getCodeTemplates(['0d42f17b-54a4-40c1-8e7b-b43c3eb1b433','37139e86-88db-41fa-bf80-8c08456caa10'])forctincodeTemplates.codeTemplates:print(f"{ct.name}-{ct.id}")# get all code templatescodeTemplates=service.getCodeTemplates()forctincodeTemplates.codeTemplates:print(f"{ct.name}-{ct.id}")code=ct.properties.find('code').textservice.close()# to log out and close any service related objectsSupported Mirth API CallsServerMirth API Routemirthpy methodDescriptionGET /server/idservice.getServerId()Gets Mirth Instance Server IdGET /server/versionservice.getVersion()Gets Mirth Instance versionPOST /server/_generateGUIDservice.getGUID()Gets Mirth specific GUID for idsGET /server/timeservice.getTime()Gets current Mirth Server timeGET /server/channelTagsservice.getTags()Gets all tagsGET /server/statsservice.getSystemStats()Gets statistics for underlying system. Timestamp, cpu usage, allocated memory, etc.GET /server/infoservice.getSystemInfo()Gets information on underlying system. JvmVersion, OS Name, OS Version, OS Architecture, etc.GET /server/configurationMapservice.getConfigurationMaps()Gets all configuration mappingsPUT /server/configurationMapservice.putConfigurationMaps(configurationMaps)Update all entries in the configuration map.EventsMirth API Routemirthpy methodDescription/eventsservice.getEvents(jsonParams)Gets mirth events, can specify what parameters to passChannelMirth API Routemirthpy methodDescriptionPOST /channelsservice.createChannel(channel, set_time?)Creates a channel in mirth instance based on channel objectPUT /channels/{channelId}service.updateChannel(channel, override?, set_time?)Updates a channel based off of channel objectDELETE /channels/{channelId}service.deleteChannel(channel, override?)Deletes a channel based off of channel idGET /channelsservice.getChannels(channelIds?, pollingOnly?, includeCodeTemplates?)Get all channels or certain channels in criteriaGET /channels/{channelId}service.getChannel(channelId, includeCodeTemplates)Get a single channelGET /channels/idsAndNamesservice.getChannelIdsAndNames()Get all channel name and idsGET /channels/idsAndNamesservice.getChannelIdByName(name)Get only the channel id based on channel namePOST /channels/_haltservice.haultChannels(channelIds?, returnErrors?)Halts a set of channels.POST /channels/_pauseservice.pauseChannels(channelIds?, returnErrors?)Pauses a set of channels.POST /channels/_resumeservice.resumeChannels(channelIds?, returnErrors?)Resumes a set of channels.POST /channels/_startservice.startChannels(channelIds?, returnErrors?)Starts a set of channels.POST /channels/_stopservice.stopChannels(channelIds?, returnErrors?)Stops a set of channels.POST /channels/{channelId}/_haltservice.haultChannel(channelId, returnErrors?)Halts a sepecified channels.POST /channels/{channelId}/_pauseservice.pauseChannels(channelId, returnErrors?)Pauses a sepecified channels.POST /channels/{channelId}/_resumeservice.resumeChannels(channelId, returnErrors?)Resumes a sepecified channels.POST /channels/{channelId}/_stopservice.stopChannel(channelId)Stop specified channelPOST /channels/{channelId}/_startservice.startChannel(channelId)Start specified channelPOST /channels/_startConnectorsservice.startConnectors(channelId, metadataIds?, returnErrors?)Start connectors based on channel id and metadata idPOST /channels/_stopConnectorsservice.stopConnectors(channelId, metadataIds?, returnErrors?)Stop connectors based on channel id and metadata idGET /channels/{channelId}/statusservice.getChannelStatus(channelId)Get the status of a channelGET /channels/statusesservice.getChannelStatuses(channelIds?, filter?, includeUndeployed?)Get the status of specified channels or allChannel StatusMirth API Routemirthpy methodDescriptionGET /channels/statusesservice.getChannelStatus(channelIds, filter, includeUndeployed)Get Dashboard status of channelsCode Template CallsMirth API Routemirthpy methodDescriptionGET /codeTemplatesservice.getCodeTemplates(codeTemplateIds)Get all or some Code TemplatesPUT /codeTemplateLibrariesservice.putCodeTemplates(codeTemplates, override?)Update code template librariesPUT /codeTemplates/{codeTemplateId}service.putCodeTemplate(codeTemplateId, codeTemplates, override?)Update a code templateMessage CallsMirth API Routemirthpy methodDescriptionGET /channels/{channelId}/messagesservice.getMessages(channelId, limit?, includeContent?, offset?, startDate?, endDate?, status?)Get messages by channelId with filtering optionsGET /channels/{channelId}/messages/countservice.getMessageCount(channelId, startDate?, endDate?, status?)Get messages count by channelId with filtering optionsChannel DeploymentMirth API Routemirthpy methodDescriptionPOST /channels/_deployservice.deployChannels(channelIds, returnErrors?)Deploy set of channelsPOST /channels/{channelId}/_deployservice.deployChannel(channelId, returnErrors?)Deploy a channelPOST /channels/_undeployservice.undeployChannels(channelIds, returnErrors?)Undeploy set of channelsPOST /channels/{channelId}/_undeployservice.undeployChannel(channelId, returnErrors?)Undeploy a channelPOST /channels/_redeployAllservice.redeployAllChannels(returnErrors?)Redeploy all channelsChannel StatisticsMirth API Routemirthpy methodDescriptionGET /channels/statisticsservice.getChannelStatistics(channelIds, includeUndeployed, includeMetadataId, excludeMetaDataId, aggregateStates)Get Channel StatisticsGET /channels/{channelId}/statisticsservice.getChannelStatistics(channelIds)Get a Channels StatisticsExtensions (Commercial License)Mirth API Routemirthpy methodDescriptionGET /extensions/history/channels/{channelId}/snapshotsservice.getChannelHistory(channelId)Get Channel HistoryGET /extensions/history/channels/{channelId}/snapshots/{snapshotId}service.getSnapshot(channelId, snapshotId)Get Channel History Snapshot